Skip to content

Commit

Permalink
apply_test files mixed up diffs (want, got) and (got, want)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Scott authored and tekton-robot committed May 28, 2020
1 parent 9ce0bab commit cc724c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/reconciler/pipelinerun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
})
Expand Down Expand Up @@ -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))
}
})
Expand Down Expand Up @@ -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))
}
})
Expand Down Expand Up @@ -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))
}
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/taskrun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
})
Expand Down Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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))
}
})
Expand Down Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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))
}
}
Expand Down

0 comments on commit cc724c8

Please sign in to comment.