From cc724c8a79bf93820824e68da22b0274fcd42989 Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 28 May 2020 11:50:40 -0400 Subject: [PATCH] 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. --- pkg/reconciler/pipelinerun/resources/apply_test.go | 8 ++++---- pkg/reconciler/taskrun/resources/apply_test.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/reconciler/pipelinerun/resources/apply_test.go b/pkg/reconciler/pipelinerun/resources/apply_test.go index 3aa82220857..ab92a183131 100644 --- a/pkg/reconciler/pipelinerun/resources/apply_test.go +++ b/pkg/reconciler/pipelinerun/resources/apply_test.go @@ -138,7 +138,7 @@ func TestApplyParameters(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := ApplyParameters(&tt.original.Spec, tt.run) - if d := cmp.Diff(got, &tt.expected.Spec); d != "" { + if d := cmp.Diff(&tt.expected.Spec, got); d != "" { t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d)) } }) @@ -211,7 +211,7 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs) - if d := cmp.Diff(tt.args.targets, tt.want); d != "" { + if d := cmp.Diff(tt.want, tt.args.targets); d != "" { t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d)) } }) @@ -284,7 +284,7 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs) - if d := cmp.Diff(tt.args.targets, tt.want); d != "" { + if d := cmp.Diff(tt.want, tt.args.targets); d != "" { t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d)) } }) @@ -378,7 +378,7 @@ func TestApplyTaskResults_Conditions(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs) - if d := cmp.Diff(tt.args.targets[0].ResolvedConditionChecks, tt.want[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(tt.want[0].ResolvedConditionChecks, tt.args.targets[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ApplyTaskResults() %s", diff.PrintWantGot(d)) } }) diff --git a/pkg/reconciler/taskrun/resources/apply_test.go b/pkg/reconciler/taskrun/resources/apply_test.go index 3fd2acc1ef6..b51ecbbdb54 100644 --- a/pkg/reconciler/taskrun/resources/apply_test.go +++ b/pkg/reconciler/taskrun/resources/apply_test.go @@ -480,7 +480,7 @@ func TestApplyArrayParameters(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := resources.ApplyParameters(tt.args.ts, tt.args.tr, tt.args.dp...) - if d := cmp.Diff(got, tt.want); d != "" { + if d := cmp.Diff(tt.want, got); d != "" { t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d)) } }) @@ -544,7 +544,7 @@ func TestApplyParameters(t *testing.T) { spec.Sidecars[0].Container.Env[0].Value = "world" }) got := resources.ApplyParameters(simpleTaskSpec, tr, dp...) - if d := cmp.Diff(got, want); d != "" { + if d := cmp.Diff(want, got); d != "" { t.Errorf("ApplyParameters() got diff %s", diff.PrintWantGot(d)) } } @@ -616,7 +616,7 @@ func TestApplyResources(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := resources.ApplyResources(tt.args.ts, tt.args.r, tt.args.rStr) - if d := cmp.Diff(got, tt.want); d != "" { + if d := cmp.Diff(tt.want, got); d != "" { t.Errorf("ApplyResources() %s", diff.PrintWantGot(d)) } }) @@ -737,7 +737,7 @@ func TestApplyWorkspaces(t *testing.T) { EmptyDir: &corev1.EmptyDirVolumeSource{}, }} got := resources.ApplyWorkspaces(ts, w, wb) - if d := cmp.Diff(got, want); d != "" { + if d := cmp.Diff(want, got); d != "" { t.Errorf("TestApplyWorkspaces() got diff %s", diff.PrintWantGot(d)) } } @@ -773,7 +773,7 @@ func TestTaskResults(t *testing.T) { spec.Steps[1].Script = "#!/usr/bin/env bash\ndate | tee /tekton/results/current-date-human-readable" }) got := resources.ApplyTaskResults(ts) - if d := cmp.Diff(got, want); d != "" { + if d := cmp.Diff(want, got); d != "" { t.Errorf("ApplyTaskResults() got diff %s", diff.PrintWantGot(d)) } }