From acd2d7370254f16719255f83035b23806f9eca44 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 4 Nov 2020 17:09:22 +0100 Subject: [PATCH] =?UTF-8?q?pkg/apis=20tests=20cleanup=20on=20duplicate=20t?= =?UTF-8?q?est=20name=20=F0=9F=92=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error/fatal message should report the name of the test. It is already available when the test fail as it is part of the name of the test. This reduces some duplication and make some tests a bit easier to read and write 😉. Signed-off-by: Vincent Demeester --- pkg/apis/pipeline/v1beta1/param_types_test.go | 2 +- .../v1beta1/pipeline_defaults_test.go | 2 +- .../v1beta1/pipeline_validation_test.go | 38 +++++++++---------- .../v1beta1/pipelinerun_types_test.go | 16 ++++---- .../v1beta1/pipelinerun_validation_test.go | 8 ++-- pkg/apis/pipeline/v1beta1/pod_test.go | 17 --------- pkg/apis/pipeline/v1beta1/resultref_test.go | 8 ++-- .../v1beta1/taskrun_validation_test.go | 10 ++--- pkg/apis/pipeline/v1beta1/when_types_test.go | 6 +-- .../pipeline/v1beta1/when_validation_test.go | 4 +- 10 files changed, 48 insertions(+), 63 deletions(-) delete mode 100644 pkg/apis/pipeline/v1beta1/pod_test.go diff --git a/pkg/apis/pipeline/v1beta1/param_types_test.go b/pkg/apis/pipeline/v1beta1/param_types_test.go index ba931bdb6e6..d3fda869fbe 100644 --- a/pkg/apis/pipeline/v1beta1/param_types_test.go +++ b/pkg/apis/pipeline/v1beta1/param_types_test.go @@ -72,7 +72,7 @@ func TestParamSpec_SetDefaults(t *testing.T) { ctx := context.Background() tc.before.SetDefaults(ctx) if d := cmp.Diff(tc.before, tc.defaultsApplied); d != "" { - t.Errorf("ParamSpec.SetDefaults/%s %s", tc.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } diff --git a/pkg/apis/pipeline/v1beta1/pipeline_defaults_test.go b/pkg/apis/pipeline/v1beta1/pipeline_defaults_test.go index 438f6654761..90a63daef3c 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_defaults_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_defaults_test.go @@ -137,7 +137,7 @@ func TestPipelineSpec_SetDefaults(t *testing.T) { ctx := context.Background() tc.ps.SetDefaults(ctx) if d := cmp.Diff(tc.want, tc.ps); d != "" { - t.Errorf("Mismatch of pipelineSpec after setting defaults: %s: %s", tc.desc, diff.PrintWantGot(d)) + t.Errorf("Mismatch of pipelineSpec after setting defaults: %s", diff.PrintWantGot(d)) } }) } diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go index d93bea81e38..4a2c18a648c 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go @@ -106,7 +106,7 @@ func TestPipeline_Validate_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.p.Validate(context.Background()) if err != nil { - t.Errorf("Pipeline.Validate() returned error for valid Pipeline: %s: %v", tt.name, err) + t.Errorf("Pipeline.Validate() returned error for valid Pipeline: %v", err) } }) } @@ -155,7 +155,7 @@ func TestPipeline_Validate_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.p.Validate(context.Background()) if err == nil { - t.Errorf("Pipeline.Validate() did not return error for invalid pipeline: %s", tt.name) + t.Error("Pipeline.Validate() did not return error for invalid pipeline") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("Pipeline.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -385,7 +385,7 @@ func TestPipelineSpec_Validate_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.ps.Validate(context.Background()) if err == nil { - t.Errorf("PipelineSpec.Validate() did not return error for invalid pipelineSpec: %s", tt.name) + t.Errorf("PipelineSpec.Validate() did not return error for invalid pipelineSpec") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -430,7 +430,7 @@ func TestValidatePipelineTasks_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineTasks(context.Background(), tt.tasks, []PipelineTask{}) if err != nil { - t.Errorf("Pipeline.validatePipelineTasks() returned error for valid pipeline tasks: %s: %v", tt.name, err) + t.Errorf("Pipeline.validatePipelineTasks() returned error for valid pipeline tasks: %v", err) } }) } @@ -520,7 +520,7 @@ func TestValidatePipelineTasks_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineTasks(context.Background(), tt.tasks, []PipelineTask{}) if err == nil { - t.Error("Pipeline.validatePipelineTasks() did not return error for invalid pipeline tasks:", tt.name) + t.Error("Pipeline.validatePipelineTasks() did not return error for invalid pipeline tasks") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -554,7 +554,7 @@ func TestValidateFrom_Success(t *testing.T) { t.Run(desc, func(t *testing.T) { err := validateFrom(tasks) if err != nil { - t.Errorf("Pipeline.validateFrom() returned error for: %s: %v", desc, err) + t.Errorf("Pipeline.validateFrom() returned error for: %v", err) } }) } @@ -668,7 +668,7 @@ func TestValidateFrom_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validateFrom(tt.tasks) if err == nil { - t.Error("Pipeline.validateFrom() did not return error for invalid pipeline task resources: ", tt.name) + t.Error("Pipeline.validateFrom() did not return error for invalid pipeline task resources") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -764,7 +764,7 @@ func TestValidateDeclaredResources_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validateDeclaredResources(tt.resources, tt.tasks, []PipelineTask{}) if err != nil { - t.Errorf("Pipeline.validateDeclaredResources() returned error for valid resource declarations: %s: %v", tt.name, err) + t.Errorf("Pipeline.validateDeclaredResources() returned error for valid resource declarations: %v", err) } }) } @@ -860,7 +860,7 @@ func TestValidateDeclaredResources_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validateDeclaredResources(tt.resources, tt.tasks, []PipelineTask{}) if err == nil { - t.Errorf("Pipeline.validateDeclaredResources() did not return error for invalid resource declarations: %s", tt.name) + t.Errorf("Pipeline.validateDeclaredResources() did not return error for invalid resource declarations") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -1062,7 +1062,7 @@ func TestValidatePipelineParameterVariables_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineParameterVariables(tt.tasks, tt.params) if err != nil { - t.Errorf("Pipeline.validatePipelineParameterVariables() returned error for valid pipeline parameters: %s: %v", tt.name, err) + t.Errorf("Pipeline.validatePipelineParameterVariables() returned error for valid pipeline parameters: %v", err) } }) } @@ -1340,7 +1340,7 @@ func TestValidatePipelineParameterVariables_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineParameterVariables(tt.tasks, tt.params) if err == nil { - t.Errorf("Pipeline.validatePipelineParameterVariables() did not return error for invalid pipeline parameters: %s", tt.name) + t.Errorf("Pipeline.validatePipelineParameterVariables() did not return error for invalid pipeline parameters") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -1362,7 +1362,7 @@ func TestValidatePipelineWorkspaces_Success(t *testing.T) { t.Run(desc, func(t *testing.T) { err := validatePipelineWorkspaces(workspaces, tasks, []PipelineTask{}) if err != nil { - t.Errorf("Pipeline.validatePipelineWorkspaces() returned error for valid pipeline workspaces: %s: %v", desc, err) + t.Errorf("Pipeline.validatePipelineWorkspaces() returned error for valid pipeline workspaces: %v", err) } }) } @@ -1420,7 +1420,7 @@ func TestValidatePipelineWorkspaces_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineWorkspaces(tt.workspaces, tt.tasks, []PipelineTask{}) if err == nil { - t.Errorf("Pipeline.validatePipelineWorkspaces() did not return error for invalid pipeline workspaces: %s", tt.name) + t.Errorf("Pipeline.validatePipelineWorkspaces() did not return error for invalid pipeline workspaces") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -1498,7 +1498,7 @@ func TestValidatePipelineWithFinalTasks_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.p.Validate(context.Background()) if err != nil { - t.Errorf("Pipeline.Validate() returned error for valid pipeline with finally: %s: %v", tt.name, err) + t.Errorf("Pipeline.Validate() returned error for valid pipeline with finally: %v", err) } }) } @@ -1731,7 +1731,7 @@ func TestValidatePipelineWithFinalTasks_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := tt.p.Validate(context.Background()) if err == nil { - t.Errorf("Pipeline.Validate() did not return error for invalid pipeline with finally: %s", tt.name) + t.Errorf("Pipeline.Validate() did not return error for invalid pipeline with finally") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -1767,7 +1767,7 @@ func TestValidateTasksAndFinallySection_Success(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validateTasksAndFinallySection(tt.ps) if err != nil { - t.Errorf("Pipeline.ValidateTasksAndFinallySection() returned error for valid pipeline with finally: %s: %v", tt.name, err) + t.Errorf("Pipeline.ValidateTasksAndFinallySection() returned error for valid pipeline with finally: %v", err) } }) } @@ -1871,7 +1871,7 @@ func TestValidateFinalTasks_Failure(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validateFinalTasks(tt.finalTasks) if err == nil { - t.Errorf("Pipeline.ValidateFinalTasks() did not return error for invalid pipeline: %s", tt.name) + t.Errorf("Pipeline.ValidateFinalTasks() did not return error for invalid pipeline") } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) @@ -1933,7 +1933,7 @@ func TestContextValid(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := validatePipelineContextVariables(tt.tasks); err != nil { - t.Errorf("Pipeline.validatePipelineContextVariables() returned error for valid pipeline context variables: %s: %v", tt.name, err) + t.Errorf("Pipeline.validatePipelineContextVariables() returned error for valid pipeline context variables: %v", err) } }) } @@ -1986,7 +1986,7 @@ func TestContextInvalid(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := validatePipelineContextVariables(tt.tasks) if err == nil { - t.Errorf("Pipeline.validatePipelineContextVariables() did not return error for invalid pipeline parameters: %s, %s", tt.name, tt.tasks[0].Params) + t.Errorf("Pipeline.validatePipelineContextVariables() did not return error for invalid pipeline parameters: %s", tt.tasks[0].Params) } if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" { t.Errorf("PipelineSpec.Validate() errors diff %s", diff.PrintWantGot(d)) diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go index 4c5785a9fe5..cedc8339873 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go @@ -304,10 +304,12 @@ func TestPipelineRunGetServiceAccountName(t *testing.T) { }, } { for taskName, expected := range tt.saNames { - sa := tt.pr.GetServiceAccountName(taskName) - if expected != sa { - t.Errorf("%s: wrong service account: got: %v, want: %v", tt.name, sa, expected) - } + t.Run(tt.name, func(t *testing.T) { + sa := tt.pr.GetServiceAccountName(taskName) + if expected != sa { + t.Errorf("wrong service account: got: %v, want: %v", sa, expected) + } + }) } } } @@ -385,7 +387,7 @@ func TestPipelineRunGetPodSpecSABackcompatibility(t *testing.T) { t.Run(tt.name, func(t *testing.T) { sa, _ := tt.pr.GetTaskRunSpecs(taskName) if expected != sa { - t.Errorf("%s: wrong service account: got: %v, want: %v", tt.name, sa, expected) + t.Errorf("wrong service account: got: %v, want: %v", sa, expected) } }) } @@ -428,10 +430,10 @@ func TestPipelineRunGetPodSpec(t *testing.T) { t.Run(tt.name, func(t *testing.T) { sa, taskPodTemplate := tt.pr.GetTaskRunSpecs(taskName) if values[0] != taskPodTemplate.SchedulerName { - t.Errorf("%s: wrong task podtemplate scheduler name: got: %v, want: %v", tt.name, taskPodTemplate.SchedulerName, values[0]) + t.Errorf("wrong task podtemplate scheduler name: got: %v, want: %v", taskPodTemplate.SchedulerName, values[0]) } if values[1] != sa { - t.Errorf("%s: wrong service account: got: %v, want: %v", tt.name, sa, values[1]) + t.Errorf("wrong service account: got: %v, want: %v", sa, values[1]) } }) } diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go index 8f52f230075..670a2643206 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go @@ -125,7 +125,7 @@ func TestPipelineRun_Invalidate(t *testing.T) { t.Run(ps.name, func(t *testing.T) { err := ps.pr.Validate(context.Background()) if d := cmp.Diff(err.Error(), ps.want.Error()); d != "" { - t.Errorf("PipelineRun.Validate/%s %s", ps.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } @@ -203,7 +203,7 @@ func TestPipelineRun_Validate(t *testing.T) { for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { if err := ts.pr.Validate(context.Background()); err != nil { - t.Errorf("Unexpected PipelineRun.Validate() error = %v", err) + t.Error(err) } }) } @@ -278,7 +278,7 @@ func TestPipelineRunSpec_Invalidate(t *testing.T) { t.Run(ps.name, func(t *testing.T) { err := ps.spec.Validate(context.Background()) if d := cmp.Diff(ps.wantErr.Error(), err.Error()); d != "" { - t.Errorf("PipelineRunSpec.Validate/%s (-want, +got) = %v", ps.name, d) + t.Error(diff.PrintWantGot(d)) } }) } @@ -304,7 +304,7 @@ func TestPipelineRunSpec_Validate(t *testing.T) { for _, ps := range tests { t.Run(ps.name, func(t *testing.T) { if err := ps.spec.Validate(context.Background()); err != nil { - t.Errorf("PipelineRunSpec.Validate/%s (-want, +got) = %v", ps.name, err) + t.Error(err) } }) } diff --git a/pkg/apis/pipeline/v1beta1/pod_test.go b/pkg/apis/pipeline/v1beta1/pod_test.go deleted file mode 100644 index 36525af19b9..00000000000 --- a/pkg/apis/pipeline/v1beta1/pod_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2019 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1_test diff --git a/pkg/apis/pipeline/v1beta1/resultref_test.go b/pkg/apis/pipeline/v1beta1/resultref_test.go index d5e3b66909c..308b6df95c2 100644 --- a/pkg/apis/pipeline/v1beta1/resultref_test.go +++ b/pkg/apis/pipeline/v1beta1/resultref_test.go @@ -116,7 +116,7 @@ func TestNewResultReference(t *testing.T) { } else { got := v1beta1.NewResultRefs(expressions) if d := cmp.Diff(tt.want, got); d != "" { - t.Errorf("TestNewResultReference/%s %s", tt.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } } }) @@ -205,7 +205,7 @@ func TestHasResultReference(t *testing.T) { return true }) if d := cmp.Diff(tt.wantRef, got); d != "" { - t.Errorf("TestHasResultReference/%s %s", tt.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } @@ -384,7 +384,7 @@ func TestNewResultReferenceWhenExpressions(t *testing.T) { } else { got := v1beta1.NewResultRefs(expressions) if d := cmp.Diff(tt.want, got); d != "" { - t.Errorf("TestNewResultReference/%s %s", tt.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } } }) @@ -459,7 +459,7 @@ func TestHasResultReferenceWhenExpression(t *testing.T) { } got := v1beta1.NewResultRefs(expressions) if d := cmp.Diff(tt.wantRef, got); d != "" { - t.Errorf("TestHasResultReference/%s %s", tt.name, diff.PrintWantGot(d)) + t.Errorf(diff.PrintWantGot(d)) } }) } diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go index 23f40035b03..119167953b6 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go @@ -58,7 +58,7 @@ func TestTaskRun_Invalidate(t *testing.T) { t.Run(ts.name, func(t *testing.T) { err := ts.task.Validate(context.Background()) if d := cmp.Diff(err.Error(), ts.want.Error()); d != "" { - t.Errorf("TaskRun.Validate/%s %s", ts.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } @@ -120,7 +120,7 @@ func TestTaskRun_Workspaces_Invalid(t *testing.T) { t.Errorf("Expected error for invalid TaskRun but got none") } if d := cmp.Diff(ts.wantErr.Error(), err.Error()); d != "" { - t.Errorf("TaskRunSpec.Validate/%s %s", ts.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } @@ -224,7 +224,7 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { t.Run(ts.name, func(t *testing.T) { err := ts.spec.Validate(context.Background()) if d := cmp.Diff(ts.wantErr.Error(), err.Error()); d != "" { - t.Errorf("TaskRunSpec.Validate/%s %s", ts.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } @@ -287,7 +287,7 @@ func TestTaskRunSpec_Validate(t *testing.T) { for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { if err := ts.spec.Validate(context.Background()); err != nil { - t.Errorf("TaskRunSpec.Validate()/%s error = %v", ts.name, err) + t.Error(err) } }) } @@ -520,7 +520,7 @@ func TestResources_Invalidate(t *testing.T) { t.Run(ts.name, func(t *testing.T) { err := ts.resources.Validate(context.Background()) if d := cmp.Diff(err.Error(), ts.wantErr.Error()); d != "" { - t.Errorf("TaskRunInputs.Validate/%s %s", ts.name, diff.PrintWantGot(d)) + t.Error(diff.PrintWantGot(d)) } }) } diff --git a/pkg/apis/pipeline/v1beta1/when_types_test.go b/pkg/apis/pipeline/v1beta1/when_types_test.go index a12ac8ab0fb..82603b528e2 100644 --- a/pkg/apis/pipeline/v1beta1/when_types_test.go +++ b/pkg/apis/pipeline/v1beta1/when_types_test.go @@ -82,7 +82,7 @@ func TestAllowsExecution(t *testing.T) { t.Run(tc.name, func(t *testing.T) { got := tc.whenExpressions.AllowsExecution() if d := cmp.Diff(tc.expected, got); d != "" { - t.Errorf("Error evaluating AllowsExecution() for When Expressions in test case %s: %s", tc.name, diff.PrintWantGot(d)) + t.Errorf("Error evaluating AllowsExecution() for When Expressions in test case %s", diff.PrintWantGot(d)) } }) } @@ -142,7 +142,7 @@ func TestHaveVariables(t *testing.T) { t.Run(tc.name, func(t *testing.T) { got := tc.whenExpressions.HaveVariables() if d := cmp.Diff(tc.expected, got); d != "" { - t.Errorf("Error evaluating HaveVariables() for When Expressions in test case %s: %s", tc.name, diff.PrintWantGot(d)) + t.Errorf("Error evaluating HaveVariables() for When Expressions in test case %s", diff.PrintWantGot(d)) } }) } @@ -263,7 +263,7 @@ func TestReplaceWhenExpressionsVariables(t *testing.T) { t.Run(tc.name, func(t *testing.T) { got := tc.whenExpressions.ReplaceWhenExpressionsVariables(tc.replacements) if d := cmp.Diff(tc.expected, got); d != "" { - t.Errorf("Error evaluating When Expressions in test case %s: %s", tc.name, diff.PrintWantGot(d)) + t.Errorf("Error evaluating When Expressions in test case %s", diff.PrintWantGot(d)) } }) } diff --git a/pkg/apis/pipeline/v1beta1/when_validation_test.go b/pkg/apis/pipeline/v1beta1/when_validation_test.go index 8375e077fed..f5243beeac9 100644 --- a/pkg/apis/pipeline/v1beta1/when_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/when_validation_test.go @@ -55,7 +55,7 @@ func TestWhenExpressions_Valid(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := tt.wes.validate(); err != nil { - t.Errorf("WhenExpressions.validate() returned an error for valid when expressions: %s, %s", tt.name, tt.wes) + t.Errorf("WhenExpressions.validate() returned an error for valid when expressions: %s", tt.wes) } }) } @@ -129,7 +129,7 @@ func TestWhenExpressions_Invalid(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := tt.wes.validate(); err == nil { - t.Errorf("WhenExpressions.validate() did not return error for invalid when expressions: %s, %s, %s", tt.name, tt.wes, err) + t.Errorf("WhenExpressions.validate() did not return error for invalid when expressions: %s, %s", tt.wes, err) } }) }