From da56347e36dc1a470118d4306d2821572c3ad14f Mon Sep 17 00:00:00 2001 From: Ivan Porto Carrero Date: Mon, 28 Nov 2022 09:26:05 -0800 Subject: [PATCH] clear golangci-lint warnings/errors --- client/keepalive.go | 3 +-- client/keepalive_test.go | 13 +++++------ client/opentelemetry.go | 5 ----- client/opentelemetry_test.go | 3 ++- client/opentracing_test.go | 3 +-- client/request_test.go | 35 +++++++++++++++--------------- client/response_test.go | 4 ++-- client/runtime.go | 6 ++--- client/runtime_test.go | 22 +++++++++---------- client_request.go | 3 +-- client_response_test.go | 9 ++++---- middleware/denco/server_test.go | 6 ++--- middleware/request_test.go | 5 ++--- middleware/untyped_request_test.go | 4 ++-- request_test.go | 7 +++--- 15 files changed, 57 insertions(+), 71 deletions(-) diff --git a/client/keepalive.go b/client/keepalive.go index e9c250d6..bc7b7fa4 100644 --- a/client/keepalive.go +++ b/client/keepalive.go @@ -2,7 +2,6 @@ package client import ( "io" - "io/ioutil" "net/http" "sync/atomic" ) @@ -50,7 +49,7 @@ func (d *drainingReadCloser) Close() error { // some bytes, but the closer ignores them to keep the underling // connection open. //nolint:errcheck - io.Copy(ioutil.Discard, d.rdr) + io.Copy(io.Discard, d.rdr) } return d.rdr.Close() } diff --git a/client/keepalive_test.go b/client/keepalive_test.go index d6b95b46..5046450c 100644 --- a/client/keepalive_test.go +++ b/client/keepalive_test.go @@ -3,7 +3,6 @@ package client import ( "bytes" "io" - "io/ioutil" "testing" "github.com/stretchr/testify/assert" @@ -39,10 +38,10 @@ func (c *countingReadCloser) Close() error { func TestDrainingReadCloser(t *testing.T) { rdr := newCountingReader(bytes.NewBufferString("There are many things to do"), false) - prevDisc := ioutil.Discard + prevDisc := io.Discard disc := bytes.NewBuffer(nil) - ioutil.Discard = disc - defer func() { ioutil.Discard = prevDisc }() + io.Discard = disc + defer func() { io.Discard = prevDisc }() buf := make([]byte, 5) ts := &drainingReadCloser{rdr: rdr} @@ -57,10 +56,10 @@ func TestDrainingReadCloser(t *testing.T) { func TestDrainingReadCloser_SeenEOF(t *testing.T) { rdr := newCountingReader(bytes.NewBufferString("There are many things to do"), true) - prevDisc := ioutil.Discard + prevDisc := io.Discard disc := bytes.NewBuffer(nil) - ioutil.Discard = disc - defer func() { ioutil.Discard = prevDisc }() + io.Discard = disc + defer func() { io.Discard = prevDisc }() buf := make([]byte, 5) ts := &drainingReadCloser{rdr: rdr} diff --git a/client/opentelemetry.go b/client/opentelemetry.go index 3b7b8391..8a38ea3e 100644 --- a/client/opentelemetry.go +++ b/client/opentelemetry.go @@ -205,8 +205,3 @@ func newConfig(opts ...OpenTelemetryOpt) *config { func version() string { return instrumentationVersion } - -// SemVersion is the semantic version to be supplied to tracer/meter creation. -func semVersion() string { - return "semver:" + version() -} diff --git a/client/opentelemetry_test.go b/client/opentelemetry_test.go index 5026fd96..94d8eadb 100644 --- a/client/opentelemetry_test.go +++ b/client/opentelemetry_test.go @@ -91,7 +91,8 @@ func Test_injectOpenTelemetrySpanContext(t *testing.T) { header := map[string][]string{} tr := newOpenTelemetryTransport(&mockRuntime{runtime.TestClientRequest{Headers: header}}, "", nil) tr.config.Propagator = propagation.TraceContext{} - tr.Submit(operation) + _, err := tr.Submit(operation) + assert.NoError(t, err) assert.Len(t, header, 1) } diff --git a/client/opentracing_test.go b/client/opentracing_test.go index 650a437f..d3df0652 100644 --- a/client/opentracing_test.go +++ b/client/opentracing_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "testing" "github.com/go-openapi/strfmt" @@ -33,7 +32,7 @@ func (r tres) GetHeaders(_ string) []string { return []string{"the headers", "the headers2"} } func (r tres) Body() io.ReadCloser { - return ioutil.NopCloser(bytes.NewBufferString("the content")) + return io.NopCloser(bytes.NewBufferString("the content")) } type mockRuntime struct { diff --git a/client/request_test.go b/client/request_test.go index a6d73af8..e6a06988 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -20,7 +20,6 @@ import ( "encoding/xml" "errors" "io" - "io/ioutil" "mime" "mime/multipart" "net/http" @@ -165,7 +164,7 @@ func TestBuildRequest_BuildHTTP_Payload(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expectedBody, _ := json.Marshal(bd) - actualBody, _ := ioutil.ReadAll(req.Body) + actualBody, _ := io.ReadAll(req.Body) assert.Equal(t, append(expectedBody, '\n'), actualBody) } } @@ -197,7 +196,7 @@ func TestBuildRequest_BuildHTTP_SetsInAuth(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expectedBody, _ := json.Marshal(bd) - actualBody, _ := ioutil.ReadAll(req.Body) + actualBody, _ := io.ReadAll(req.Body) assert.Equal(t, append(expectedBody, '\n'), actualBody) } } @@ -224,7 +223,7 @@ func TestBuildRequest_BuildHTTP_XMLPayload(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expectedBody, _ := xml.Marshal(bd) - actualBody, _ := ioutil.ReadAll(req.Body) + actualBody, _ := io.ReadAll(req.Body) assert.Equal(t, expectedBody, actualBody) } } @@ -247,7 +246,7 @@ func TestBuildRequest_BuildHTTP_TextPayload(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expectedBody := []byte(bd) - actualBody, _ := ioutil.ReadAll(req.Body) + actualBody, _ := io.ReadAll(req.Body) assert.Equal(t, expectedBody, actualBody) } } @@ -269,7 +268,7 @@ func TestBuildRequest_BuildHTTP_Form(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expected := []byte("something=some+value") - actual, _ := ioutil.ReadAll(req.Body) + actual, _ := io.ReadAll(req.Body) assert.Equal(t, expected, actual) } } @@ -292,7 +291,7 @@ func TestBuildRequest_BuildHTTP_Form_URLEncoded(t *testing.T) { assert.Equal(t, "world", req.URL.Query().Get("hello")) assert.Equal(t, "/flats/1234/", req.URL.Path) expected := []byte("something=some+value") - actual, _ := ioutil.ReadAll(req.Body) + actual, _ := io.ReadAll(req.Body) assert.Equal(t, expected, actual) } } @@ -316,7 +315,7 @@ func TestBuildRequest_BuildHTTP_Form_Content_Length(t *testing.T) { assert.Condition(t, func() bool { return req.ContentLength > 0 }, "ContentLength must great than 0. got %d", req.ContentLength) expected := []byte("something=some+value") - actual, _ := ioutil.ReadAll(req.Body) + actual, _ := io.ReadAll(req.Body) assert.Equal(t, expected, actual) } } @@ -339,7 +338,7 @@ func TestBuildRequest_BuildHTTP_FormMultipart(t *testing.T) { assert.Equal(t, "/flats/1234/", req.URL.Path) expected1 := []byte("Content-Disposition: form-data; name=\"something\"") expected2 := []byte("some value") - actual, _ := ioutil.ReadAll(req.Body) + actual, _ := io.ReadAll(req.Body) actuallines := bytes.Split(actual, []byte("\r\n")) assert.Equal(t, 6, len(actuallines)) boundary := string(actuallines[0]) @@ -371,7 +370,7 @@ func TestBuildRequest_BuildHTTP_FormMultiples(t *testing.T) { expected1 := []byte("Content-Disposition: form-data; name=\"something\"") expected2 := []byte("some value") expected3 := []byte("another value") - actual, _ := ioutil.ReadAll(req.Body) + actual, _ := io.ReadAll(req.Body) actuallines := bytes.Split(actual, []byte("\r\n")) assert.Equal(t, 10, len(actuallines)) boundary := string(actuallines[0]) @@ -388,8 +387,8 @@ func TestBuildRequest_BuildHTTP_FormMultiples(t *testing.T) { } func TestBuildRequest_BuildHTTP_Files(t *testing.T) { - cont, _ := ioutil.ReadFile("./runtime.go") - cont2, _ := ioutil.ReadFile("./request.go") + cont, _ := os.ReadFile("./runtime.go") + cont2, _ := os.ReadFile("./request.go") reqWrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error { _ = req.SetFormParam("something", "some value") _ = req.SetFileParam("file", mustGetFile("./runtime.go")) @@ -420,7 +419,7 @@ func TestBuildRequest_BuildHTTP_Files(t *testing.T) { mpf, _ := mpff.Open() defer mpf.Close() assert.Equal(t, filename, mpff.Filename) - actual, _ := ioutil.ReadAll(mpf) + actual, _ := io.ReadAll(mpf) assert.Equal(t, content, actual) } fileverifier("file", 0, "runtime.go", cont) @@ -432,8 +431,8 @@ func TestBuildRequest_BuildHTTP_Files(t *testing.T) { } } func TestBuildRequest_BuildHTTP_Files_URLEncoded(t *testing.T) { - cont, _ := ioutil.ReadFile("./runtime.go") - cont2, _ := ioutil.ReadFile("./request.go") + cont, _ := os.ReadFile("./runtime.go") + cont2, _ := os.ReadFile("./request.go") reqWrtr := runtime.ClientRequestWriterFunc(func(req runtime.ClientRequest, reg strfmt.Registry) error { _ = req.SetFormParam("something", "some value") _ = req.SetFileParam("file", mustGetFile("./runtime.go")) @@ -464,7 +463,7 @@ func TestBuildRequest_BuildHTTP_Files_URLEncoded(t *testing.T) { mpf, _ := mpff.Open() defer mpf.Close() assert.Equal(t, filename, mpff.Filename) - actual, _ := ioutil.ReadAll(mpf) + actual, _ := io.ReadAll(mpf) assert.Equal(t, content, actual) } fileverifier("file", 0, "runtime.go", cont) @@ -611,7 +610,7 @@ func TestGetBodyCallsBeforeRoundTrip(t *testing.T) { // Read the body once before sending the request body, err := req.GetBody() require.NoError(t, err) - bodyContent, err := ioutil.ReadAll(io.Reader(body)) + bodyContent, err := io.ReadAll(io.Reader(body)) require.EqualValues(t, req.ContentLength, len(bodyContent)) require.NoError(t, err) require.EqualValues(t, "\"test body\"\n", string(bodyContent)) @@ -619,7 +618,7 @@ func TestGetBodyCallsBeforeRoundTrip(t *testing.T) { // Read the body a second time before sending the request body, err = req.GetBody() require.NoError(t, err) - bodyContent, err = ioutil.ReadAll(io.Reader(body)) + bodyContent, err = io.ReadAll(io.Reader(body)) require.NoError(t, err) require.EqualValues(t, req.ContentLength, len(bodyContent)) require.EqualValues(t, "\"test body\"\n", string(bodyContent)) diff --git a/client/response_test.go b/client/response_test.go index 5d4694ee..458dd047 100644 --- a/client/response_test.go +++ b/client/response_test.go @@ -16,7 +16,7 @@ package client import ( "bytes" - "io/ioutil" + "io" "net/http" "testing" @@ -31,7 +31,7 @@ func TestResponse(t *testing.T) { under.StatusCode = 392 under.Header = make(http.Header) under.Header.Set("Blah", "blah blah") - under.Body = ioutil.NopCloser(bytes.NewBufferString("some content")) + under.Body = io.NopCloser(bytes.NewBufferString("some content")) var resp runtime.ClientResponse = response{under} assert.EqualValues(t, under.StatusCode, resp.Code()) diff --git a/client/runtime.go b/client/runtime.go index bf80a438..ccec0413 100644 --- a/client/runtime.go +++ b/client/runtime.go @@ -23,10 +23,10 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "mime" "net/http" "net/http/httputil" + "os" "strings" "sync" "time" @@ -164,7 +164,7 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) { cfg.RootCAs = caCertPool } else if opts.CA != "" { // load ca cert - caCert, err := ioutil.ReadFile(opts.CA) + caCert, err := os.ReadFile(opts.CA) if err != nil { return nil, fmt.Errorf("tls client ca: %v", err) } @@ -181,8 +181,6 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) { cfg.ServerName = opts.ServerName } - cfg.BuildNameToCertificate() - return cfg, nil } diff --git a/client/runtime_test.go b/client/runtime_test.go index 415ebeec..3c4c7c50 100644 --- a/client/runtime_test.go +++ b/client/runtime_test.go @@ -19,7 +19,7 @@ import ( "encoding/json" "encoding/xml" "errors" - "io/ioutil" + "io" "net/http" "net/http/cookiejar" "net/http/httptest" @@ -70,7 +70,7 @@ func TestRuntime_TLSAuthConfig(t *testing.T) { } func TestRuntime_TLSAuthConfigWithRSAKey(t *testing.T) { - keyPem, err := ioutil.ReadFile("../fixtures/certs/myclient.key") + keyPem, err := os.ReadFile("../fixtures/certs/myclient.key") require.NoError(t, err) keyDer, _ := pem.Decode(keyPem) @@ -79,7 +79,7 @@ func TestRuntime_TLSAuthConfigWithRSAKey(t *testing.T) { key, err := x509.ParsePKCS1PrivateKey(keyDer.Bytes) require.NoError(t, err) - certPem, err := ioutil.ReadFile("../fixtures/certs/myclient.crt") + certPem, err := os.ReadFile("../fixtures/certs/myclient.crt") require.NoError(t, err) certDer, _ := pem.Decode(certPem) @@ -101,7 +101,7 @@ func TestRuntime_TLSAuthConfigWithRSAKey(t *testing.T) { } func TestRuntime_TLSAuthConfigWithECKey(t *testing.T) { - keyPem, err := ioutil.ReadFile("../fixtures/certs/myclient-ecc.key") + keyPem, err := os.ReadFile("../fixtures/certs/myclient-ecc.key") require.NoError(t, err) _, remainder := pem.Decode(keyPem) @@ -111,7 +111,7 @@ func TestRuntime_TLSAuthConfigWithECKey(t *testing.T) { key, err := x509.ParseECPrivateKey(keyDer.Bytes) require.NoError(t, err) - certPem, err := ioutil.ReadFile("../fixtures/certs/myclient-ecc.crt") + certPem, err := os.ReadFile("../fixtures/certs/myclient-ecc.crt") require.NoError(t, err) certDer, _ := pem.Decode(certPem) @@ -133,7 +133,7 @@ func TestRuntime_TLSAuthConfigWithECKey(t *testing.T) { } func TestRuntime_TLSAuthConfigWithLoadedCA(t *testing.T) { - certPem, err := ioutil.ReadFile("../fixtures/certs/myCA.crt") + certPem, err := os.ReadFile("../fixtures/certs/myCA.crt") require.NoError(t, err) block, _ := pem.Decode(certPem) @@ -154,7 +154,7 @@ func TestRuntime_TLSAuthConfigWithLoadedCA(t *testing.T) { } func TestRuntime_TLSAuthConfigWithLoadedCAPool(t *testing.T) { - certPem, err := ioutil.ReadFile("../fixtures/certs/myCA.crt") + certPem, err := os.ReadFile("../fixtures/certs/myCA.crt") require.NoError(t, err) block, _ := pem.Decode(certPem) @@ -182,7 +182,7 @@ func TestRuntime_TLSAuthConfigWithLoadedCAPool(t *testing.T) { } func TestRuntime_TLSAuthConfigWithLoadedCAPoolAndLoadedCA(t *testing.T) { - certPem, err := ioutil.ReadFile("../fixtures/certs/myCA.crt") + certPem, err := os.ReadFile("../fixtures/certs/myCA.crt") require.NoError(t, err) block, _ := pem.Decode(certPem) @@ -251,7 +251,7 @@ func TestRuntime_ManualCertificateValidation(t *testing.T) { // root cert rootCertFile := "../fixtures/certs/myCA.crt" - rootCertPem, err := ioutil.ReadFile(rootCertFile) + rootCertPem, err := os.ReadFile(rootCertFile) require.NoError(t, err) rootCertRaw, _ := pem.Decode(rootCertPem) require.NotNil(t, rootCertRaw) @@ -623,7 +623,7 @@ func TestRuntime_CustomTransport(t *testing.T) { buf := bytes.NewBuffer(nil) enc := json.NewEncoder(buf) _ = enc.Encode(result) - resp.Body = ioutil.NopCloser(buf) + resp.Body = io.NopCloser(buf) return &resp, nil }) @@ -969,7 +969,7 @@ func (o *overrideRoundTripper) RoundTrip(req *http.Request) (*http.Response, err o.overriden = true res := new(http.Response) res.StatusCode = 200 - res.Body = ioutil.NopCloser(bytes.NewBufferString("OK")) + res.Body = io.NopCloser(bytes.NewBufferString("OK")) return res, nil } diff --git a/client_request.go b/client_request.go index 3efda348..d4d2b58f 100644 --- a/client_request.go +++ b/client_request.go @@ -16,7 +16,6 @@ package runtime import ( "io" - "io/ioutil" "net/http" "net/url" "time" @@ -79,7 +78,7 @@ type NamedReadCloser interface { func NamedReader(name string, rdr io.Reader) NamedReadCloser { rc, ok := rdr.(io.ReadCloser) if !ok { - rc = ioutil.NopCloser(rdr) + rc = io.NopCloser(rdr) } return &namedReadCloser{ name: name, diff --git a/client_response_test.go b/client_response_test.go index d84719ba..75a67586 100644 --- a/client_response_test.go +++ b/client_response_test.go @@ -19,7 +19,6 @@ import ( "errors" "io" "io/fs" - "io/ioutil" "strings" "testing" @@ -42,7 +41,7 @@ func (r response) GetHeaders(_ string) []string { return []string{"the headers", "the headers2"} } func (r response) Body() io.ReadCloser { - return ioutil.NopCloser(bytes.NewBufferString("the content")) + return io.NopCloser(bytes.NewBufferString("the content")) } func TestResponseReaderFunc(t *testing.T) { @@ -51,7 +50,7 @@ func TestResponseReaderFunc(t *testing.T) { Code int } reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (interface{}, error) { - b, _ := ioutil.ReadAll(r.Body()) + b, _ := io.ReadAll(r.Body()) actual.Body = string(b) actual.Code = r.Code() actual.Message = r.Message() @@ -67,7 +66,7 @@ func TestResponseReaderFunc(t *testing.T) { func TestResponseReaderFuncError(t *testing.T) { reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (interface{}, error) { - _, _ = ioutil.ReadAll(r.Body()) + _, _ = io.ReadAll(r.Body()) return nil, NewAPIError("fake", errors.New("writer closed"), 490) }) _, err := reader.ReadResponse(response{}, nil) @@ -75,7 +74,7 @@ func TestResponseReaderFuncError(t *testing.T) { assert.True(t, strings.Contains(err.Error(), "writer closed"), err.Error()) reader = func(r ClientResponse, _ Consumer) (interface{}, error) { - _, _ = ioutil.ReadAll(r.Body()) + _, _ = io.ReadAll(r.Body()) err := &fs.PathError{ Op: "write", Path: "path/to/fake", diff --git a/middleware/denco/server_test.go b/middleware/denco/server_test.go index 4ef43e4f..a2562847 100644 --- a/middleware/denco/server_test.go +++ b/middleware/denco/server_test.go @@ -2,7 +2,7 @@ package denco_test import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -59,7 +59,7 @@ func TestMux(t *testing.T) { continue } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { t.Error(err) continue @@ -94,7 +94,7 @@ func TestNotFound(t *testing.T) { t.Fatal(err) } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { t.Fatal(err) } diff --git a/middleware/request_test.go b/middleware/request_test.go index 4970c9e4..65ef69ad 100644 --- a/middleware/request_test.go +++ b/middleware/request_test.go @@ -17,7 +17,6 @@ package middleware import ( "bytes" "io" - "io/ioutil" "mime/multipart" "net/http" "net/url" @@ -435,7 +434,7 @@ func TestBindingFileUpload(t *testing.T) { assert.NotNil(t, data.File.Header) assert.Equal(t, "plain-jane.txt", data.File.Header.Filename) - bb, err := ioutil.ReadAll(data.File.Data) + bb, err := io.ReadAll(data.File.Data) assert.NoError(t, err) assert.Equal(t, []byte("the file contents"), bb) @@ -525,7 +524,7 @@ func TestBindingOptionalFileUpload(t *testing.T) { assert.NotNil(t, data.File.Header) assert.Equal(t, "plain-jane.txt", data.File.Header.Filename) - bb, err := ioutil.ReadAll(data.File.Data) + bb, err := io.ReadAll(data.File.Data) assert.NoError(t, err) assert.Equal(t, []byte("the file contents"), bb) } diff --git a/middleware/untyped_request_test.go b/middleware/untyped_request_test.go index 93f70841..f156f350 100644 --- a/middleware/untyped_request_test.go +++ b/middleware/untyped_request_test.go @@ -18,7 +18,7 @@ import ( "bytes" "encoding/base64" "encoding/json" - "io/ioutil" + "io" "mime/multipart" "net/http" "net/url" @@ -77,7 +77,7 @@ func TestUntypedFileUpload(t *testing.T) { assert.NotNil(t, file.Header) assert.Equal(t, "plain-jane.txt", file.Header.Filename) - bb, err := ioutil.ReadAll(file.Data) + bb, err := io.ReadAll(file.Data) assert.NoError(t, err) assert.Equal(t, []byte("the file contents"), bb) diff --git a/request_test.go b/request_test.go index 38500719..7dec2aec 100644 --- a/request_test.go +++ b/request_test.go @@ -18,7 +18,6 @@ import ( "bufio" "bytes" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -89,7 +88,7 @@ func TestPeekingReader(t *testing.T) { // just passes to original reader when nothing called exp1 := []byte("original") pr1 := newPeekingReader(closeReader(bytes.NewReader(exp1))) - b1, err := ioutil.ReadAll(pr1) + b1, err := io.ReadAll(pr1) if assert.NoError(t, err) { assert.Equal(t, exp1, b1) } @@ -100,7 +99,7 @@ func TestPeekingReader(t *testing.T) { peeked, err := pr2.underlying.Peek(1) require.NoError(t, err) require.Equal(t, "a", string(peeked)) - b2, err := ioutil.ReadAll(pr2) + b2, err := io.ReadAll(pr2) if assert.NoError(t, err) { assert.Equal(t, string(exp2), string(b2)) } @@ -132,7 +131,7 @@ func TestPeekingReader(t *testing.T) { require.Equal(t, 1, cbr.peeks) require.Equal(t, 0, cbr.reads) - b, err := ioutil.ReadAll(pr) + b, err := io.ReadAll(pr) require.NoError(t, err) require.Equal(t, "hello", string(b)) require.Equal(t, 2, cbr.buffereds)