MCPcopy
hub / github.com/dgraph-io/dgraph / cacheControlHeader

Function cacheControlHeader

graphql/e2e/common/query.go:96–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func cacheControlHeader(t *testing.T) {
97 query := &GraphQLParams{
98 Query: `query @cacheControl(maxAge: 5) {
99 queryCountry {
100 name
101 }
102 }`,
103 }
104 req, err := query.CreateGQLPost(GraphqlURL)
105 require.NoError(t, err)
106
107 client := http.Client{Timeout: 10 * time.Second}
108 resp, err := client.Do(req)
109 require.NoError(t, err)
110 defer func() { require.NoError(t, resp.Body.Close()) }()
111
112 // confirm that the header value is a non-negative integer
113 require.Equal(t, "public,max-age=5", resp.Header.Get("Cache-Control"))
114 require.Equal(t, "Accept-Encoding", resp.Header.Get("Vary"))
115}
116
117// This test checks that all the different combinations of
118// request sending compressed / uncompressed query and receiving

Callers

nothing calls this directly

Calls 3

CreateGQLPostMethod · 0.95
CloseMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected