func TestHTTPCaching(t *testing.T) { srv := mockServer() ts := time.Now().Unix() fm := models.EmptyFeatureMap() fm.Dcdr.Info.CurrentSHA = "current-sha" fm.Dcdr.Info.LastModifiedDate = ts srv.Client.SetFeatureMap(fm) resp := builder.WithMux(srv). Get(srv.config.Server.Endpoint). Header(middleware.IfNoneMatchHeader, fm.Dcdr.Info.CurrentSHA).Do() http_assert.Response(t, resp.Response). HasStatusCode(http.StatusNotModified). ContainsHeaderValue(middleware.EtagHeader, fm.Dcdr.CurrentSHA()). ContainsHeaderValue(middleware.LastModifiedHeader, time.Unix(ts, 0).Format(time.RFC1123)). ContainsHeaderValue(middleware.CacheControlHeader, middleware.CacheControl). ContainsHeaderValue(middleware.PragmaHeader, middleware.Pragma). ContainsHeaderValue(middleware.ExpiresHeader, middleware.Expires) resp = builder.WithMux(srv). Get(srv.config.Server.Endpoint). Header(middleware.IfNoneMatchHeader, "").Do() http_assert.Response(t, resp.Response). HasStatusCode(http.StatusOK). ContainsHeaderValue(middleware.EtagHeader, fm.Dcdr.CurrentSHA()). ContainsHeaderValue(middleware.CacheControlHeader, middleware.CacheControl). ContainsHeaderValue(middleware.PragmaHeader, middleware.Pragma). ContainsHeaderValue(middleware.ExpiresHeader, middleware.Expires) }
func TestGetFeatures(t *testing.T) { srv := mockServer() resp := builder.WithMux(srv).Get(srv.config.Server.Endpoint).Do() http_assert.Response(t, resp.Response). IsOK(). IsJSON() var m models.FeatureMap err := resp.Response.UnmarshalBody(&m) assert.NoError(t, err) assert.Equal(t, cl.ScopedMap(), &m) }
func TestScopeHeader(t *testing.T) { srv := mockServer() resp := builder.WithMux(srv). Get(srv.config.Server.Endpoint). Header(handlers.DcdrScopesHeader, "scope, scope2").Do() http_assert.Response(t, resp.Response). IsOK(). IsJSON(). ContainsHeaderValue(handlers.DcdrScopesHeader, "scope, scope2") var m models.FeatureMap err := resp.Response.UnmarshalBody(&m) assert.NoError(t, err) assert.Equal(t, cl.WithScopes("scope").ScopedMap(), &m) }