Skip to content

Commit

Permalink
Mark unused arguments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielNagy committed Feb 20, 2024
1 parent 635b5ba commit 5e57584
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion internal/ad/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/adsysservice/adsysservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/daemon/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
10 changes: 5 additions & 5 deletions internal/grpc/connectionnotify/connectionnotify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++

Expand Down Expand Up @@ -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++

Expand All @@ -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")
}

Expand All @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions internal/grpc/contextidler/contextidler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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)
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/interceptorschain/chainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/logconnections/logconnections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/logstreamer/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions internal/grpc/logstreamer/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/policies/policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 },
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/policies/scripts/scripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5e57584

Please sign in to comment.