MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestResponseEncoding

Function TestResponseEncoding

rest/api_test.go:1337–1360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1335}
1336
1337func TestResponseEncoding(t *testing.T) {
1338 // Make a doc longer than 1k so the HTTP response will be compressed:
1339 str := "DORKY "
1340 for i := 0; i < 10; i++ {
1341 str = str + str
1342 }
1343 docJSON := fmt.Sprintf(`{"long": %q}`, str)
1344
1345 rt := NewRestTester(t, nil)
1346 defer rt.Close()
1347
1348 response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/_local/loc1", docJSON)
1349 RequireStatus(t, response, 201)
1350 response = rt.SendAdminRequestWithHeaders("GET", "/{{.keyspace}}/_local/loc1", "",
1351 map[string]string{"Accept-Encoding": "foo, gzip, bar"})
1352 RequireStatus(t, response, 200)
1353 assert.Equal(t, "gzip", response.Header().Get("Content-Encoding"))
1354 unzip, err := gzip.NewReader(response.Body)
1355 assert.NoError(t, err)
1356 unjson := base.JSONDecoder(unzip)
1357 var body db.Body
1358 assert.Equal(t, nil, unjson.Decode(&body))
1359 assert.Equal(t, str, body["long"])
1360}
1361
1362func TestAllDocsChannelsAfterChannelMove(t *testing.T) {
1363

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
SendAdminRequestMethod · 0.95
JSONDecoderFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
HeaderMethod · 0.80
DecodeMethod · 0.65
EqualMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected