From 5e57584d96d49434a643bb14309840412fa5961d Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Tue, 20 Feb 2024 17:42:27 +0200 Subject: [PATCH] Mark unused arguments in tests --- internal/ad/registry/registry_test.go | 2 +- internal/adsysservice/adsysservice_test.go | 2 +- internal/daemon/daemon_test.go | 2 +- internal/daemon/export_test.go | 2 +- .../grpc/connectionnotify/connectionnotify_test.go | 10 +++++----- internal/grpc/contextidler/contextidler_test.go | 10 +++++----- internal/grpc/interceptorschain/chainer_test.go | 2 +- internal/grpc/logconnections/logconnections_test.go | 2 +- internal/grpc/logstreamer/client_test.go | 2 +- internal/grpc/logstreamer/server_test.go | 8 ++++---- internal/policies/policies_test.go | 4 ++-- internal/policies/scripts/scripts_test.go | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/ad/registry/registry_test.go b/internal/ad/registry/registry_test.go index 0a2040bfa..633de6b12 100644 --- a/internal/ad/registry/registry_test.go +++ b/internal/ad/registry/registry_test.go @@ -429,7 +429,7 @@ func FuzzDecodePolicy(f *testing.F) { f.Add(d) } - f.Fuzz(func(t *testing.T, d []byte) { + f.Fuzz(func(_ *testing.T, d []byte) { r := bytes.NewReader(d) _, _ = registry.DecodePolicy(r) }) diff --git a/internal/adsysservice/adsysservice_test.go b/internal/adsysservice/adsysservice_test.go index 67c8a9516..03cdfcf6f 100644 --- a/internal/adsysservice/adsysservice_test.go +++ b/internal/adsysservice/adsysservice_test.go @@ -179,7 +179,7 @@ func TestMain(m *testing.M) { Value: uint64(1234), Writable: false, Emit: prop.EmitTrue, - Callback: func(c *prop.Change) *dbus.Error { + Callback: func(_ *prop.Change) *dbus.Error { return nil }, }, diff --git a/internal/daemon/daemon_test.go b/internal/daemon/daemon_test.go index 0be8afba2..5338a1f46 100644 --- a/internal/daemon/daemon_test.go +++ b/internal/daemon/daemon_test.go @@ -239,7 +239,7 @@ func TestSdNotifier(t *testing.T) { d, err := daemon.New(grpcRegister.registerGRPCServer, "/tmp/this/is/ignored", daemon.WithSystemdActivationListener(func() ([]net.Listener, error) { return []net.Listener{l}, nil }), - daemon.WithSystemdSdNotifier(func(unsetEnvironment bool, state string) (bool, error) { + daemon.WithSystemdSdNotifier(func(_ bool, _ string) (bool, error) { if tc.notifierFail { return false, errors.New("systemd notifier error") } diff --git a/internal/daemon/export_test.go b/internal/daemon/export_test.go index 7b86eff1f..06f390297 100644 --- a/internal/daemon/export_test.go +++ b/internal/daemon/export_test.go @@ -20,7 +20,7 @@ func WithSystemdSdNotifier(f func(unsetEnvironment bool, state string) (bool, er } func FailingOption() func(o *options) error { - return func(o *options) error { + return func(_ *options) error { return errors.New("failing option") } } diff --git a/internal/grpc/connectionnotify/connectionnotify_test.go b/internal/grpc/connectionnotify/connectionnotify_test.go index ffe242dc6..2310434cf 100644 --- a/internal/grpc/connectionnotify/connectionnotify_test.go +++ b/internal/grpc/connectionnotify/connectionnotify_test.go @@ -28,7 +28,7 @@ func TestNoNotification(t *testing.T) { pingued, s := struct{}{}, struct{}{} var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ return nil @@ -59,7 +59,7 @@ func TestNewConnectionNotification(t *testing.T) { s := struct{}{} var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ @@ -92,7 +92,7 @@ func TestDoneConnectionNotification(t *testing.T) { s := struct{}{} var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ @@ -111,7 +111,7 @@ func TestErrorFromHandlerReturned(t *testing.T) { pingued, s := struct{}{}, struct{}{} - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { return errors.New("Any error") } @@ -124,7 +124,7 @@ func TestErrorOnNilStream(t *testing.T) { pingued, s := struct{}{}, struct{}{} - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { return nil } diff --git a/internal/grpc/contextidler/contextidler_test.go b/internal/grpc/contextidler/contextidler_test.go index eb9a4c93a..ed811a7fc 100644 --- a/internal/grpc/contextidler/contextidler_test.go +++ b/internal/grpc/contextidler/contextidler_test.go @@ -19,7 +19,7 @@ func TestActiveConnection(t *testing.T) { var s *clientStream - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(ctx context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { s = &clientStream{ctx: ctx} return s, nil } @@ -42,7 +42,7 @@ func TestTimeoutOnInactiveConnection(t *testing.T) { var s *clientStream - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(ctx context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { s = &clientStream{ctx: ctx} return s, nil } @@ -63,7 +63,7 @@ func TestCancelOnClientSide(t *testing.T) { clientCtx, clientCancel := context.WithCancel(context.Background()) - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(ctx context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { s = &clientStream{ctx: ctx} return s, nil } @@ -81,7 +81,7 @@ func TestCancelOnClientSide(t *testing.T) { func TestClientInterceptorFailed(t *testing.T) { t.Parallel() - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(_ context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { return nil, errors.New("My interceptor error") } _, err := contextidler.StreamClientInterceptor(0)(context.Background(), nil, nil, "method", streamCreation) @@ -94,7 +94,7 @@ func TestRecvMessageError(t *testing.T) { var s *clientStream childErr := errors.New("Server error") - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(ctx context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { s = &clientStream{wantErrRecvMsg: childErr, ctx: ctx} return s, nil } diff --git a/internal/grpc/interceptorschain/chainer_test.go b/internal/grpc/interceptorschain/chainer_test.go index 41f1f29fc..b5b1270fe 100644 --- a/internal/grpc/interceptorschain/chainer_test.go +++ b/internal/grpc/interceptorschain/chainer_test.go @@ -90,7 +90,7 @@ func TestStreamClient(t *testing.T) { wrappedCtx := context.WithValue(ctx, keyCtxType("second"), 44) return streamer(wrappedCtx, desc, cc, method, wrappedOpts...) } - streamer := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamer := func(ctx context.Context, desc *grpc.StreamDesc, _ *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { require.Equal(t, someServiceName, method, "streamer must know someService") require.Equal(t, fakeStreamDesc, desc, "streamer must see the right StreamDesc") diff --git a/internal/grpc/logconnections/logconnections_test.go b/internal/grpc/logconnections/logconnections_test.go index 8a81662da..201aad2a1 100644 --- a/internal/grpc/logconnections/logconnections_test.go +++ b/internal/grpc/logconnections/logconnections_test.go @@ -61,7 +61,7 @@ func TestChildRecvMsgAndHandlerCalled(t *testing.T) { var callHandlerNum int var loggerStream grpc.ServerStream - var handler grpc.StreamHandler = func(srv interface{}, stream grpc.ServerStream) error { + var handler grpc.StreamHandler = func(_ interface{}, stream grpc.ServerStream) error { loggerStream = stream callHandlerNum++ var err error diff --git a/internal/grpc/logstreamer/client_test.go b/internal/grpc/logstreamer/client_test.go index e9ff6b11f..7a005eb55 100644 --- a/internal/grpc/logstreamer/client_test.go +++ b/internal/grpc/logstreamer/client_test.go @@ -146,7 +146,7 @@ func TestRecvLogMsg(t *testing.T) { wantErrRecvMsg: tc.errRecv, } - streamCreation := func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) { + streamCreation := func(_ context.Context, _ *grpc.StreamDesc, _ *grpc.ClientConn, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) { return s, nil } c, err := log.StreamClientInterceptor(logger)(context.Background(), nil, nil, "method", streamCreation) diff --git a/internal/grpc/logstreamer/server_test.go b/internal/grpc/logstreamer/server_test.go index 6d50d7e3c..090057840 100644 --- a/internal/grpc/logstreamer/server_test.go +++ b/internal/grpc/logstreamer/server_test.go @@ -44,7 +44,7 @@ func TestStreamServerInterceptor(t *testing.T) { callOrder := 1 var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ return nil @@ -70,7 +70,7 @@ func TestStreamServerInterceptorSendLogsFails(t *testing.T) { callOrder := 1 var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ return nil @@ -115,7 +115,7 @@ func TestStreamServerInterceptorLoggerInvalidMetadata(t *testing.T) { callOrder := 1 var handlerCalled int - handler := func(srv interface{}, stream grpc.ServerStream) error { + handler := func(_ interface{}, _ grpc.ServerStream) error { handlerCalled = callOrder callOrder++ return nil @@ -168,7 +168,7 @@ func msgContains(t *testing.T, expected string, msg interface{}, description str func createLogStream(t *testing.T, level logrus.Level, callerForLocal, callerForRemote bool, sendError error) (stream grpc.ServerStream, localLogs func() string, remoteLogs func() string) { t.Helper() - handler := func(srv interface{}, s grpc.ServerStream) error { + handler := func(_ interface{}, s grpc.ServerStream) error { stream = s return nil } diff --git a/internal/policies/policies_test.go b/internal/policies/policies_test.go index c608e59c8..45d561840 100644 --- a/internal/policies/policies_test.go +++ b/internal/policies/policies_test.go @@ -487,7 +487,7 @@ func TestCompressAssets(t *testing.T) { // We need a fixed modification and creation time on our assets to have reproducible test // on zip modification time stored for content. fixedTime := time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC) - err := filepath.WalkDir(p, func(path string, d os.DirEntry, err error) error { + err := filepath.WalkDir(p, func(path string, _ os.DirEntry, _ error) error { return os.Chtimes(path, fixedTime, fixedTime) }) require.NoError(t, err, "Setup: can’t set fixed time for assets") @@ -957,7 +957,7 @@ func TestMain(m *testing.M) { Value: true, Writable: true, Emit: prop.EmitTrue, - Callback: func(c *prop.Change) *dbus.Error { return nil }, + Callback: func(_ *prop.Change) *dbus.Error { return nil }, }, }, } diff --git a/internal/policies/scripts/scripts_test.go b/internal/policies/scripts/scripts_test.go index 0723720e1..d857ae0de 100644 --- a/internal/policies/scripts/scripts_test.go +++ b/internal/policies/scripts/scripts_test.go @@ -181,7 +181,7 @@ func makeIndependentOfCurrentUID(t *testing.T, path string, uid string) { // We need to rename at the end, starting from the leaf to the start so that we don’t fail filepath.Walk() // walking in currently renamed directory. var toRename []string - err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(path, func(path string, _ os.FileInfo, err error) error { if err != nil { return err }