Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestInsertIntoCHAt_success(t *testing.T) {
func TestInsertIntoCHAt_serverError(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte("oops")) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte("oops"))
}))
defer srv.Close()
err := insertIntoCHAt(t.Context(), srv.Client(), srv.URL, []byte("payload"), true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestWriteDataToFile(t *testing.T) {
if err := writeDataToFile(p, []byte("xyz")); err != nil {
t.Fatal(err)
}
b, _ := os.ReadFile(p) //nolint:errcheck // test plumbing
b, _ := os.ReadFile(p)
if string(b) != "xyz" {
t.Errorf("got %q, want xyz", b)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/kafka_to_clickhouse/kafka_to_clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestWriteDataToFile_badPath(t *testing.T) {

func TestGetLatestSchemaIDAt_happy(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(`{"id":99}`)) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte(`{"id":99}`))
}))
defer srv.Close()
got, err := getLatestSchemaIDAt(context.Background(), srv.Client(), srv.URL, "subj")
Expand All @@ -96,7 +96,7 @@ func TestGetLatestSchemaIDAt_happy(t *testing.T) {

func TestGetLatestSchemaIDAt_badJSON(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("not json")) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte("not json"))
}))
defer srv.Close()
if _, err := getLatestSchemaIDAt(context.Background(), srv.Client(), srv.URL, "subj"); err == nil {
Expand All @@ -116,7 +116,7 @@ func TestGetLatestSchemaIDAt_connRefused(t *testing.T) {
func TestGetLatestSchemaIDAt_ctxCancel(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
time.Sleep(50 * time.Millisecond)
_, _ = w.Write([]byte(`{"id":1}`)) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte(`{"id":1}`))
}))
defer srv.Close()
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestDestKafka_unreachable(t *testing.T) {

payload := []byte("payload")
c := config{topic: "test-topic", debugLevel: 11}
n, _ := destKafka(ctx, c, &payload) //nolint:errcheck // err is logged inside the callback
n, _ := destKafka(ctx, c, &payload)
if n != 1 {
t.Errorf("n = %d, want 1 (Produce was attempted)", n)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/ns/ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ func TestRunMain_profileMode(t *testing.T) {
// Profile mode "cpu" sets a deferred stopper. Run from tempdir so
// the .pprof file ends up there.
dir := t.TempDir()
wd, _ := os.Getwd() //nolint:errcheck // test plumbing
wd, _ := os.Getwd()
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = os.Chdir(wd) }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = os.Chdir(wd) })
rc := runMain(t.Context(), []string{"-profile.mode", "cpu"}, &strings.Builder{}, &strings.Builder{})
if rc != 0 {
t.Errorf("rc = %d, want 0", rc)
Expand Down Expand Up @@ -223,11 +223,11 @@ func TestStartProfile_eachMode(t *testing.T) {
// to ProfilePath("."). Run from a tempdir + stop immediately so the
// .pprof files end up in t.TempDir() and clean up with the test.
dir := t.TempDir()
wd, _ := os.Getwd() //nolint:errcheck // test plumbing
wd, _ := os.Getwd()
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = os.Chdir(wd) }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = os.Chdir(wd) })

// Iterate every supported mode. Each pass starts the profile and
// immediately stops it before the next mode begins.
Expand Down
12 changes: 6 additions & 6 deletions cmd/register_schema/register_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestReadProtobufFromFile_missing(t *testing.T) {
func TestRegisterProtobufSchemaAt_happy(t *testing.T) {
var gotBody string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body) //nolint:errcheck // test plumbing
body, _ := io.ReadAll(r.Body)
gotBody = string(body)
w.WriteHeader(http.StatusOK)
}))
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestRegisterProtobufSchemaAt_connRefused(t *testing.T) {

func TestGetLatestSchemaIDAt_happy(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`{"id":42}`)) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte(`{"id":42}`))
}))
defer srv.Close()
got, err := getLatestSchemaIDAt(srv.Client(), srv.URL, "subject")
Expand All @@ -90,7 +90,7 @@ func TestGetLatestSchemaIDAt_happy(t *testing.T) {

func TestGetLatestSchemaIDAt_badJSON(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("not json")) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte("not json"))
}))
defer srv.Close()
if _, err := getLatestSchemaIDAt(srv.Client(), srv.URL, "subject"); err == nil {
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestRunMain_getOnly(t *testing.T) {
w.WriteHeader(http.StatusInternalServerError)
return
}
_, _ = w.Write([]byte(`{"id":7}`)) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte(`{"id":7}`))
}))
defer srv.Close()

Expand All @@ -155,7 +155,7 @@ func TestRunMain_registerThenGet(t *testing.T) {
}
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
_, _ = w.Write([]byte(`{"id":42}`)) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte(`{"id":42}`))
return
}
w.WriteHeader(http.StatusOK)
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestRunMain_getError(t *testing.T) {
t.Fatal(err)
}
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("not json")) //nolint:errcheck // test plumbing
_, _ = w.Write([]byte("not json"))
}))
defer srv.Close()

Expand Down
10 changes: 5 additions & 5 deletions cmd/xtcp2/xtcp2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func TestGetDeserializers(t *testing.T) {
if tc.envSet {
t.Setenv("DESERIALIZERS", tc.envOverride)
} else {
os.Unsetenv("DESERIALIZERS") //nolint:errcheck // test cleanup; t.Setenv reverts after the test
os.Unsetenv("DESERIALIZERS")
}
got := getDeserializers(tc.input)
if got == nil {
Expand Down Expand Up @@ -580,11 +580,11 @@ func TestPrintConfig(t *testing.T) {
done := make(chan struct{})
var out strings.Builder
go func() {
_, _ = io.Copy(&out, r) //nolint:errcheck // test plumbing
_, _ = io.Copy(&out, r)
close(done)
}()
printConfig(c, "test snapshot")
_ = w.Close() //nolint:errcheck // test plumbing
_ = w.Close()
<-done
if !strings.Contains(out.String(), "test snapshot") || !strings.Contains(out.String(), "protobufList") {
t.Errorf("printConfig should include comment + fields; got %q", out.String())
Expand Down Expand Up @@ -658,11 +658,11 @@ func TestPrintFlags(t *testing.T) {
sink.Add(1)
go func() {
defer sink.Done()
_, _ = io.Copy(io.Discard, r) //nolint:errcheck // test plumbing
_, _ = io.Copy(io.Discard, r)
close(done)
}()
printFlags(f)
_ = w.Close() //nolint:errcheck // test plumbing
_ = w.Close()
<-done
}

Expand Down
14 changes: 7 additions & 7 deletions cmd/xtcp2client/xtcp2client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewGRPCClient(t *testing.T) {
if conn == nil {
t.Fatal("newGRPCClient returned nil")
}
_ = conn.Close() //nolint:errcheck // test plumbing
_ = conn.Close()
}

func TestPrintFlatRecordsResponse_silent(t *testing.T) {
Expand Down Expand Up @@ -184,11 +184,11 @@ func startRecordingGRPC(t *testing.T) (addr string, cleanup func()) {
srv := grpc.NewServer()
xtcp_flat_record.RegisterXTCPFlatRecordServiceServer(srv, &recordingFRServer{})
go func() {
_ = srv.Serve(lis) //nolint:errcheck // test plumbing
_ = srv.Serve(lis)
}()
return lis.Addr().String(), func() {
srv.Stop()
_ = lis.Close() //nolint:errcheck // test plumbing
_ = lis.Close()
}
}

Expand All @@ -201,11 +201,11 @@ func startTestGRPC(t *testing.T) (addr string, cleanup func()) {
srv := grpc.NewServer()
xtcp_flat_record.RegisterXTCPFlatRecordServiceServer(srv, &noopFRServer{})
go func() {
_ = srv.Serve(lis) //nolint:errcheck // test plumbing
_ = srv.Serve(lis)
}()
return lis.Addr().String(), func() {
srv.Stop()
_ = lis.Close() //nolint:errcheck // test plumbing
_ = lis.Close()
}
}

Expand Down Expand Up @@ -310,7 +310,7 @@ func TestStream_recordingServer(t *testing.T) {
defer cancel()

conn := newGRPCClient(addr)
defer func() { _ = conn.Close() }() //nolint:errcheck // test plumbing
defer func() { _ = conn.Close() }()

wg := new(sync.WaitGroup)
wg.Add(1)
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestStream_dialAndCancel(t *testing.T) {
defer cancel()

conn := newGRPCClient(addr)
defer func() { _ = conn.Close() }() //nolint:errcheck // test plumbing
defer func() { _ = conn.Close() }()

wg := new(sync.WaitGroup)
wg.Add(1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/misc/misc_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ func TestPrintMemUsage(t *testing.T) {
var out strings.Builder
done := make(chan struct{})
go func() {
_, _ = io.Copy(&out, r) //nolint:errcheck // test plumbing
_, _ = io.Copy(&out, r)
close(done)
}()
PrintMemUsage()
_ = w.Close() //nolint:errcheck // test plumbing
_ = w.Close()
<-done
if !strings.Contains(out.String(), "Alloc") {
t.Errorf("PrintMemUsage should print Alloc; got %q", out.String())
Expand Down
4 changes: 2 additions & 2 deletions pkg/xsync/pool.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Package xsync provides thin, generic, type-safe wrappers over the
// standard library's sync.Pool (and, later, sync.Map). The point is to
// move the single unavoidable type assertion into one provably-correct
// place so call sites get a typed value back and need no scattered
// `v, _ := p.Get().(*T) //nolint:errcheck`.
// place so call sites get a typed value back instead of a scattered
// `v, _ := p.Get().(*T)` plus an errcheck suppression at every site.
package xsync

import "sync"
Expand Down
10 changes: 5 additions & 5 deletions pkg/xtcp/destinations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func TestUDPDest_SendIoUringHappy(t *testing.T) {
if err != nil {
t.Fatalf("newUDPDest: %v", err)
}
t.Cleanup(func() { _ = d.Close() }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = d.Close() })

// Build a real io_uring ring + stash it in ctx via ringCtxKey.
ring, err := xioRingNew(t)
Expand Down Expand Up @@ -571,7 +571,7 @@ func TestUDPDest_SendIoUringNoRing(t *testing.T) {
if err != nil {
t.Fatalf("newUDPDest: %v", err)
}
t.Cleanup(func() { _ = d.Close() }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = d.Close() })

buf := []byte("ioring")
// Pass a bare ctx (no ring stashed) → expect errNoRingInCtx.
Expand Down Expand Up @@ -681,7 +681,7 @@ func TestUnixDest_SendIoUringNoRing(t *testing.T) {
if err != nil {
t.Fatalf("newUnixDest: %v", err)
}
t.Cleanup(func() { _ = d.Close() }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = d.Close() })
buf := []byte("ioring")
if _, err := d.Send(context.Background(), &buf); err == nil {
t.Error("expected errNoRingInCtx when no ring in context")
Expand All @@ -701,7 +701,7 @@ func TestUnixDest_SendIoUringHappy(t *testing.T) {
if err != nil {
t.Fatalf("newUnixDest: %v", err)
}
t.Cleanup(func() { _ = d.Close() }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = d.Close() })

ring, err := xioRingNew(t)
if err != nil {
Expand Down Expand Up @@ -732,7 +732,7 @@ func TestUnixGramDest_SendIoUringNoRing(t *testing.T) {
if err != nil {
t.Fatalf("newUnixGramDest: %v", err)
}
t.Cleanup(func() { _ = d.Close() }) //nolint:errcheck // test plumbing
t.Cleanup(func() { _ = d.Close() })

buf := []byte("ioring")
if _, err := d.Send(context.Background(), &buf); err == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/xtcp/grpc_flatRecordService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func setupBufconnServer(t *testing.T, s *xtcpFlatRecordService) (*grpc.ClientCon
srv := grpc.NewServer()
xtcp_flat_record.RegisterXTCPFlatRecordServiceServer(srv, s)
go func() {
_ = srv.Serve(lis) //nolint:errcheck // test plumbing
_ = srv.Serve(lis)
}()
dialer := func(_ context.Context, _ string) (net.Conn, error) {
return lis.Dial()
Expand All @@ -120,7 +120,7 @@ func setupBufconnServer(t *testing.T, s *xtcpFlatRecordService) (*grpc.ClientCon
t.Fatal(err)
}
cleanup := func() {
_ = conn.Close() //nolint:errcheck // test plumbing
_ = conn.Close()
srv.Stop()
}
return conn, cleanup
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestFlatRecords_bufconnCancelExits(t *testing.T) {
}

cancel()
_, _ = stream.Recv() //nolint:errcheck // test plumbing
_, _ = stream.Recv()
time.Sleep(50 * time.Millisecond)
if got := srvSvc.frMapCount(); got != 0 {
t.Errorf("frMapCount = %d, want 0 after close", got)
Expand Down
4 changes: 2 additions & 2 deletions pkg/xtcp/init_capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func withCapMask(t *testing.T, eff uint32, body func()) {
// doesn't panic.
func TestCheckCapabilities_doesntPanic(t *testing.T) {
x := &XTCP{}
_ = x.checkCapabilities() //nolint:errcheck // result is environment-dependent
_ = x.checkCapabilities()
}

func TestCheckCapabilities_debugLog(t *testing.T) {
x := &XTCP{debugLevel: 11}
_ = x.checkCapabilities() //nolint:errcheck // result is environment-dependent
_ = x.checkCapabilities()
}

// Both hard-required caps present → checkCapabilities returns nil.
Expand Down
8 changes: 4 additions & 4 deletions pkg/xtcp/ns_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func TestCreateNetlinkersAndStore_zeroNetlinkers(t *testing.T) {
t.Skipf("socketpair: %v", err)
}
defer func() {
_ = unix.Close(fds[0]) //nolint:errcheck // test plumbing
_ = unix.Close(fds[1]) //nolint:errcheck // test plumbing
_ = unix.Close(fds[0])
_ = unix.Close(fds[1])
}()

x := newNsExtraFixture(t)
Expand Down Expand Up @@ -121,8 +121,8 @@ func TestCreateNetlinkersAndStore_spawnsNetlinkers(t *testing.T) {
t.Skipf("socketpair: %v", err)
}
defer func() {
_ = unix.Close(fds[0]) //nolint:errcheck // test plumbing
_ = unix.Close(fds[1]) //nolint:errcheck // test plumbing
_ = unix.Close(fds[0])
_ = unix.Close(fds[1])
}()

x := newNsExtraFixture(t)
Expand Down
Loading