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

Function TestBytesReadGzipRequest

rest/bytes_read_public_api_test.go:389–419  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

387}
388
389func TestBytesReadGzipRequest(t *testing.T) {
390 // Need default collection as request below doesn't work with {{.keyspace}}
391 rt := NewRestTesterDefaultCollection(t, &RestTesterConfig{
392 GuestEnabled: true,
393 })
394 defer rt.Close()
395
396 rt.CreateUser("alice", []string{"ABC"})
397 input := `{"channel":["ABC"]}`
398
399 var buf bytes.Buffer
400 gz := gzip.NewWriter(&buf)
401 _, err := gz.Write([]byte(input))
402 require.NoError(t, err)
403 err = gz.Close()
404 require.NoError(t, err)
405
406 inputBytes := []byte(input)
407
408 // {{.keyspace}} isn't supported so use default collection
409 rq := Request("PUT", "/db/doc", buf.String())
410 rq.Header.Set("Content-Encoding", "gzip")
411 resp := rt.Send(rq)
412 RequireStatus(t, resp, http.StatusCreated)
413
414 base.RequireWaitForStat(t, func() int64 {
415 fmt.Println(rt.GetDatabase().DbStats.DatabaseStats.PublicRestBytesRead.Value())
416 return rt.GetDatabase().DbStats.DatabaseStats.PublicRestBytesRead.Value()
417 }, int64(len(inputBytes)))
418
419}
420
421func TestPutDBBytesRead(t *testing.T) {
422 if base.UnitTestUrlIsWalrus() {

Callers

nothing calls this directly

Calls 12

RequireWaitForStatFunction · 0.92
RequestFunction · 0.85
RequireStatusFunction · 0.85
CreateUserMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.65
SendMethod · 0.65
WriteMethod · 0.45
SetMethod · 0.45
ValueMethod · 0.45
GetDatabaseMethod · 0.45

Tested by

no test coverage detected