diff --git a/pkg/shp/cmd/build/run_test.go b/pkg/shp/cmd/build/run_test.go index 0f1316743..5a4f56f3f 100644 --- a/pkg/shp/cmd/build/run_test.go +++ b/pkg/shp/cmd/build/run_test.go @@ -119,13 +119,13 @@ func TestStartBuildRunFollowLog(t *testing.T) { // need this reactor since the Run method uses the ObjectMeta.GenerateName k8s feature to generate the random // name for the BuildRun. However, for our purposes with unit testing, we want to control the name of the BuildRun // to facilitate the list/selector via labels that is also employed by the Run method. - createReactorFunc := func(action fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { + createReactorFunc := func(_ fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { return true, br, nil } shpclientset.PrependReactor("create", "buildruns", createReactorFunc) // need this reactor to handle returning our test BuildRun with whatever updates we make based on the various // test bools that result in spec.state or deletion timestamp updates - getReactorFunc := func(action fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { + getReactorFunc := func(_ fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { return true, br, nil } shpclientset.PrependReactor("get", "buildruns", getReactorFunc) diff --git a/pkg/shp/cmd/buildrun/logs_test.go b/pkg/shp/cmd/buildrun/logs_test.go index 8acdb37fa..b4d7ad1ce 100644 --- a/pkg/shp/cmd/buildrun/logs_test.go +++ b/pkg/shp/cmd/buildrun/logs_test.go @@ -153,13 +153,13 @@ func TestStreamBuildRunFollowLogs(t *testing.T) { // need this reactor since the Run method uses the ObjectMeta.GenerateName k8s feature to generate the random // name for the BuildRun. However, for our purposes with unit testing, we want to control the name of the BuildRun // to facilitate the list/selector via labels that is also employed by the Run method. - createReactorFunc := func(action fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { + createReactorFunc := func(_ fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { return true, br, nil } shpclientset.PrependReactor("create", "buildruns", createReactorFunc) // need this reactor to handle returning our test BuildRun with whatever updates we make based on the various // test bools that result in spec.state or deletion timestamp updates - getReactorFunc := func(action fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { + getReactorFunc := func(_ fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { return true, br, nil } shpclientset.PrependReactor("get", "buildruns", getReactorFunc) diff --git a/pkg/shp/cmd/runner/runner_test.go b/pkg/shp/cmd/runner/runner_test.go index 4475b5a56..cc20003ea 100644 --- a/pkg/shp/cmd/runner/runner_test.go +++ b/pkg/shp/cmd/runner/runner_test.go @@ -40,13 +40,13 @@ func TestCMD_Runner(t *testing.T) { genericStreams := &genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr} r := NewRunner(p, genericStreams, &mockedSubCommand{}) - t.Run("cmd", func(t *testing.T) { + t.Run("cmd", func(_ *testing.T) { cmd := r.Cmd() g.Expect(cmd.RunE).ToNot(gomega.BeNil()) }) - t.Run("RunE", func(t *testing.T) { + t.Run("RunE", func(_ *testing.T) { err := r.RunE(testCmd, []string{}) g.Expect(err).To(gomega.BeNil()) diff --git a/pkg/shp/cmd/version/version.go b/pkg/shp/cmd/version/version.go index 818187162..7e7eacb46 100644 --- a/pkg/shp/cmd/version/version.go +++ b/pkg/shp/cmd/version/version.go @@ -18,7 +18,7 @@ func Command() *cobra.Command { Annotations: map[string]string{ "commandType": "main", }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if version == "" { version = "development" } diff --git a/pkg/shp/flags/build_test.go b/pkg/shp/flags/build_test.go index 4cbea5e4d..b387652f5 100644 --- a/pkg/shp/flags/build_test.go +++ b/pkg/shp/flags/build_test.go @@ -63,7 +63,7 @@ func TestBuildSpecFromFlags(t *testing.T) { flags := cmd.PersistentFlags() spec := BuildSpecFromFlags(flags) - t.Run(".spec.source", func(t *testing.T) { + t.Run(".spec.source", func(_ *testing.T) { err := flags.Set(SourceURLFlag, *expected.Source.URL) g.Expect(err).To(o.BeNil()) @@ -82,7 +82,7 @@ func TestBuildSpecFromFlags(t *testing.T) { g.Expect(expected.Source).To(o.Equal(spec.Source), "spec.source") }) - t.Run(".spec.strategy", func(t *testing.T) { + t.Run(".spec.strategy", func(_ *testing.T) { err := flags.Set(StrategyKindFlag, string(buildv1alpha1.ClusterBuildStrategyKind)) g.Expect(err).To(o.BeNil()) @@ -92,7 +92,7 @@ func TestBuildSpecFromFlags(t *testing.T) { g.Expect(expected.Strategy).To(o.Equal(spec.Strategy), "spec.strategy") }) - t.Run(".spec.dockerfile", func(t *testing.T) { + t.Run(".spec.dockerfile", func(_ *testing.T) { err := flags.Set(DockerfileFlag, *expected.Dockerfile) g.Expect(err).To(o.BeNil()) @@ -100,7 +100,7 @@ func TestBuildSpecFromFlags(t *testing.T) { g.Expect(*expected.Dockerfile).To(o.Equal(*spec.Dockerfile), "spec.dockerfile") }) - t.Run(".spec.builder", func(t *testing.T) { + t.Run(".spec.builder", func(_ *testing.T) { err := flags.Set(BuilderImageFlag, expected.Builder.Image) g.Expect(err).To(o.BeNil()) @@ -110,7 +110,7 @@ func TestBuildSpecFromFlags(t *testing.T) { g.Expect(*expected.Builder).To(o.Equal(*spec.Builder), "spec.builder") }) - t.Run(".spec.output", func(t *testing.T) { + t.Run(".spec.output", func(_ *testing.T) { err := flags.Set(OutputImageFlag, expected.Output.Image) g.Expect(err).To(o.BeNil()) @@ -123,35 +123,35 @@ func TestBuildSpecFromFlags(t *testing.T) { g.Expect(expected.Output).To(o.Equal(spec.Output), "spec.output") }) - t.Run(".spec.timeout", func(t *testing.T) { + t.Run(".spec.timeout", func(_ *testing.T) { err := flags.Set(TimeoutFlag, expected.Timeout.Duration.String()) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Timeout).To(o.Equal(*spec.Timeout), "spec.timeout") }) - t.Run(".spec.retention.failedLimit", func(t *testing.T) { + t.Run(".spec.retention.failedLimit", func(_ *testing.T) { err := flags.Set(RetentionFailedLimitFlag, strconv.FormatUint(uint64(*expected.Retention.FailedLimit), 10)) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Retention.FailedLimit).To(o.Equal(*spec.Retention.FailedLimit), "spec.retention.failedLimit") }) - t.Run(".spec.retention.succeededLimit", func(t *testing.T) { + t.Run(".spec.retention.succeededLimit", func(_ *testing.T) { err := flags.Set(RetentionSucceededLimitFlag, strconv.FormatUint(uint64(*expected.Retention.SucceededLimit), 10)) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Retention.SucceededLimit).To(o.Equal(*spec.Retention.SucceededLimit), "spec.retention.succeededLimit") }) - t.Run(".spec.retention.ttlAfterFailed", func(t *testing.T) { + t.Run(".spec.retention.ttlAfterFailed", func(_ *testing.T) { err := flags.Set(RetentionTTLAfterFailedFlag, expected.Retention.TTLAfterFailed.Duration.String()) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Retention.TTLAfterFailed).To(o.Equal(*spec.Retention.TTLAfterFailed), "spec.retention.ttlAfterFailed") }) - t.Run(".spec.retention.ttlAfterSucceeded", func(t *testing.T) { + t.Run(".spec.retention.ttlAfterSucceeded", func(_ *testing.T) { err := flags.Set(RetentionTTLAfterSucceededFlag, expected.Retention.TTLAfterSucceeded.Duration.String()) g.Expect(err).To(o.BeNil()) @@ -276,7 +276,7 @@ func TestSanitizeBuildSpec(t *testing.T) { }} for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { + t.Run(tt.name, func(_ *testing.T) { aCopy := tt.in.DeepCopy() SanitizeBuildSpec(aCopy) g.Expect(tt.out).To(o.Equal(*aCopy)) diff --git a/pkg/shp/flags/buildrun_test.go b/pkg/shp/flags/buildrun_test.go index c8a0bf239..6374f5555 100644 --- a/pkg/shp/flags/buildrun_test.go +++ b/pkg/shp/flags/buildrun_test.go @@ -50,14 +50,14 @@ func TestBuildRunSpecFromFlags(t *testing.T) { flags := cmd.PersistentFlags() spec := BuildRunSpecFromFlags(flags) - t.Run(".spec.buildRef", func(t *testing.T) { + t.Run(".spec.buildRef", func(_ *testing.T) { err := flags.Set(BuildrefNameFlag, expected.BuildRef.Name) g.Expect(err).To(o.BeNil()) g.Expect(*expected.BuildRef).To(o.Equal(*spec.BuildRef), "spec.buildRef") }) - t.Run(".spec.serviceAccount", func(t *testing.T) { + t.Run(".spec.serviceAccount", func(_ *testing.T) { err := flags.Set(ServiceAccountNameFlag, *expected.ServiceAccount.Name) g.Expect(err).To(o.BeNil()) @@ -67,14 +67,14 @@ func TestBuildRunSpecFromFlags(t *testing.T) { g.Expect(*expected.ServiceAccount).To(o.Equal(*spec.ServiceAccount), "spec.serviceAccount") }) - t.Run(".spec.timeout", func(t *testing.T) { + t.Run(".spec.timeout", func(_ *testing.T) { err := flags.Set(TimeoutFlag, expected.Timeout.Duration.String()) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Timeout).To(o.Equal(*spec.Timeout), "spec.timeout") }) - t.Run(".spec.output", func(t *testing.T) { + t.Run(".spec.output", func(_ *testing.T) { err := flags.Set(OutputImageFlag, expected.Output.Image) g.Expect(err).To(o.BeNil()) @@ -84,14 +84,14 @@ func TestBuildRunSpecFromFlags(t *testing.T) { g.Expect(*expected.Output).To(o.Equal(*spec.Output), "spec.output") }) - t.Run(".spec.retention.ttlAfterFailed", func(t *testing.T) { + t.Run(".spec.retention.ttlAfterFailed", func(_ *testing.T) { err := flags.Set(RetentionTTLAfterFailedFlag, expected.Retention.TTLAfterFailed.Duration.String()) g.Expect(err).To(o.BeNil()) g.Expect(*expected.Retention.TTLAfterFailed).To(o.Equal(*spec.Retention.TTLAfterFailed), "spec.retention.ttlAfterFailed") }) - t.Run(".spec.retention.ttlAfterSucceeded", func(t *testing.T) { + t.Run(".spec.retention.ttlAfterSucceeded", func(_ *testing.T) { err := flags.Set(RetentionTTLAfterSucceededFlag, expected.Retention.TTLAfterSucceeded.Duration.String()) g.Expect(err).To(o.BeNil()) @@ -146,7 +146,7 @@ func TestSanitizeBuildRunSpec(t *testing.T) { }} for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { + t.Run(tt.name, func(_ *testing.T) { aCopy := tt.in.DeepCopy() SanitizeBuildRunSpec(aCopy) g.Expect(tt.out).To(o.Equal(*aCopy)) diff --git a/pkg/shp/params/params_test.go b/pkg/shp/params/params_test.go index bae35d0da..1bc16cfa6 100644 --- a/pkg/shp/params/params_test.go +++ b/pkg/shp/params/params_test.go @@ -22,7 +22,7 @@ func TestParamsCreation(t *testing.T) { g.Expect(err).To(gomega.BeNil(), "Must not be an error during client creation") g.Expect(client).ToNot(gomega.BeNil(), "Client must not be nil") - t.Run("Namespace", func(t *testing.T) { + t.Run("Namespace", func(_ *testing.T) { ns := shpParams.Namespace() g.Expect(ns).To(gomega.Equal("test")) diff --git a/pkg/shp/reactor/pod_watcher_test.go b/pkg/shp/reactor/pod_watcher_test.go index 2e1d9d65a..4f91b8622 100644 --- a/pkg/shp/reactor/pod_watcher_test.go +++ b/pkg/shp/reactor/pod_watcher_test.go @@ -25,7 +25,7 @@ func Test_PodWatcher_RequestTimeout(t *testing.T) { g.Expect(err).To(o.BeNil()) called := false - pw.WithTimeoutPodFn(func(msg string) { + pw.WithTimeoutPodFn(func(_ string) { called = true }) @@ -45,7 +45,7 @@ func Test_PodWatcher_ContextTimeout(t *testing.T) { g.Expect(err).To(o.BeNil()) called := false - pw.WithTimeoutPodFn(func(msg string) { + pw.WithTimeoutPodFn(func(_ string) { called = true }) @@ -68,7 +68,7 @@ func Test_PodWatcher_NotCalledYet(t *testing.T) { eventsDoneCh := make(chan bool, 1) called := false - pw.WithNoPodEventsYetFn(func(podList *corev1.PodList) { + pw.WithNoPodEventsYetFn(func(_ *corev1.PodList) { called = true eventsCh <- true }) @@ -100,7 +100,7 @@ func Test_PodWatcher_NotCalledYet_AllEventsBeforeWatchStart(t *testing.T) { clientset := fake.NewSimpleClientset() // set up lister that will return pod, but we don't create/update a Pod, thus we do not trigger // events on the watch; mimics a Pod completing before the watch is established. - listReactorFunc := func(action fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { + listReactorFunc := func(_ fakekubetesting.Action) (handled bool, ret kruntime.Object, err error) { pod := corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, @@ -166,16 +166,16 @@ func Test_PodWatcherEvents(t *testing.T) { // adding functions to be triggered on all types of events, and sending the function name over // the events channel - pw.WithSkipPodFn(func(pod *corev1.Pod) bool { + pw.WithSkipPodFn(func(_ *corev1.Pod) bool { eventsCh <- skipPODFn return false - }).WithOnPodAddedFn(func(pod *corev1.Pod) error { + }).WithOnPodAddedFn(func(_ *corev1.Pod) error { eventsCh <- onPodAddedFn return nil - }).WithOnPodDeletedFn(func(pod *corev1.Pod) error { + }).WithOnPodDeletedFn(func(_ *corev1.Pod) error { eventsCh <- onPodDeletedFn return nil - }).WithOnPodModifiedFn(func(pod *corev1.Pod) error { + }).WithOnPodModifiedFn(func(_ *corev1.Pod) error { eventsCh <- onPodModifiedFn return nil })