Skip to content

Commit cc724c8

Browse files
Scotttekton-robot
authored andcommitted
apply_test files mixed up diffs (want, got) and (got, want)
While reviewing a PR to add helpers around cmp.Diff I noticed that these apply_test files used both orderings (got, want) and (want, got) in their tests. I've updated the tests to use ordering of (want, got) uniformly.
1 parent 9ce0bab commit cc724c8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkg/reconciler/pipelinerun/resources/apply_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func TestApplyParameters(t *testing.T) {
138138
for _, tt := range tests {
139139
t.Run(tt.name, func(t *testing.T) {
140140
got := ApplyParameters(&tt.original.Spec, tt.run)
141-
if d := cmp.Diff(got, &tt.expected.Spec); d != "" {
141+
if d := cmp.Diff(&tt.expected.Spec, got); d != "" {
142142
t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d))
143143
}
144144
})
@@ -211,7 +211,7 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) {
211211
for _, tt := range tests {
212212
t.Run(tt.name, func(t *testing.T) {
213213
ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs)
214-
if d := cmp.Diff(tt.args.targets, tt.want); d != "" {
214+
if d := cmp.Diff(tt.want, tt.args.targets); d != "" {
215215
t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d))
216216
}
217217
})
@@ -284,7 +284,7 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) {
284284
for _, tt := range tests {
285285
t.Run(tt.name, func(t *testing.T) {
286286
ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs)
287-
if d := cmp.Diff(tt.args.targets, tt.want); d != "" {
287+
if d := cmp.Diff(tt.want, tt.args.targets); d != "" {
288288
t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d))
289289
}
290290
})
@@ -378,7 +378,7 @@ func TestApplyTaskResults_Conditions(t *testing.T) {
378378
for _, tt := range tests {
379379
t.Run(tt.name, func(t *testing.T) {
380380
ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs)
381-
if d := cmp.Diff(tt.args.targets[0].ResolvedConditionChecks, tt.want[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" {
381+
if d := cmp.Diff(tt.want[0].ResolvedConditionChecks, tt.args.targets[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" {
382382
t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d))
383383
}
384384
})

pkg/reconciler/taskrun/resources/apply_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func TestApplyArrayParameters(t *testing.T) {
480480
for _, tt := range tests {
481481
t.Run(tt.name, func(t *testing.T) {
482482
got := resources.ApplyParameters(tt.args.ts, tt.args.tr, tt.args.dp...)
483-
if d := cmp.Diff(got, tt.want); d != "" {
483+
if d := cmp.Diff(tt.want, got); d != "" {
484484
t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d))
485485
}
486486
})
@@ -544,7 +544,7 @@ func TestApplyParameters(t *testing.T) {
544544
spec.Sidecars[0].Container.Env[0].Value = "world"
545545
})
546546
got := resources.ApplyParameters(simpleTaskSpec, tr, dp...)
547-
if d := cmp.Diff(got, want); d != "" {
547+
if d := cmp.Diff(want, got); d != "" {
548548
t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d))
549549
}
550550
}
@@ -616,7 +616,7 @@ func TestApplyResources(t *testing.T) {
616616
for _, tt := range tests {
617617
t.Run(tt.name, func(t *testing.T) {
618618
got := resources.ApplyResources(tt.args.ts, tt.args.r, tt.args.rStr)
619-
if d := cmp.Diff(got, tt.want); d != "" {
619+
if d := cmp.Diff(tt.want, got); d != "" {
620620
t.Errorf("ApplyResources() %s", diff.PrintWantGot(d))
621621
}
622622
})
@@ -737,7 +737,7 @@ func TestApplyWorkspaces(t *testing.T) {
737737
EmptyDir: &corev1.EmptyDirVolumeSource{},
738738
}}
739739
got := resources.ApplyWorkspaces(ts, w, wb)
740-
if d := cmp.Diff(got, want); d != "" {
740+
if d := cmp.Diff(want, got); d != "" {
741741
t.Errorf("TestApplyWorkspaces() got diff %s", diff.PrintWantGot(d))
742742
}
743743
}
@@ -773,7 +773,7 @@ func TestTaskResults(t *testing.T) {
773773
spec.Steps[1].Script = "#!/usr/bin/env bash\ndate | tee /tekton/results/current-date-human-readable"
774774
})
775775
got := resources.ApplyTaskResults(ts)
776-
if d := cmp.Diff(got, want); d != "" {
776+
if d := cmp.Diff(want, got); d != "" {
777777
t.Errorf("ApplyTaskResults() got diff %s", diff.PrintWantGot(d))
778778
}
779779
}

0 commit comments

Comments
 (0)