Skip to content

Commit

Permalink
refactor TestReconcile_PipelineSpecTaskSpec result
Browse files Browse the repository at this point in the history
update the expected result to be YAML over direct object initialization

Signed-off-by: jbpratt <jbpratt78@gmail.com>
  • Loading branch information
jbpratt authored and tekton-robot committed Mar 2, 2022
1 parent b145b54 commit f1f0aee
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var (
}

ignoreResourceVersion = cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion")
ignoreTypeMeta = cmpopts.IgnoreFields(metav1.TypeMeta{}, "Kind", "APIVersion")
trueb = true
simpleHelloWorldTask = &v1beta1.Task{ObjectMeta: baseObjectMeta("hello-world", "foo")}
simpleSomeTask = &v1beta1.Task{ObjectMeta: baseObjectMeta("some-task", "foo")}
Expand Down Expand Up @@ -1012,25 +1013,21 @@ spec:

// Check that the expected TaskRun was created
actual := getTaskRunCreations(t, actions)[0]
expectedTaskRun := &v1beta1.TaskRun{
ObjectMeta: taskRunObjectMeta("test-pipeline-run-success-unit-test-task-spec", "foo", "test-pipeline-run-success", "test-pipeline", "unit-test-task-spec", false),
Spec: v1beta1.TaskRunSpec{
TaskSpec: &v1beta1.TaskSpec{
Steps: []v1beta1.Step{{
Container: corev1.Container{
Name: "mystep",
Image: "myimage",
},
}},
},
ServiceAccountName: config.DefaultServiceAccountValue,
Resources: &v1beta1.TaskRunResources{},
Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
},
}
expectedTaskRun := parse.MustParseTaskRun(t, fmt.Sprintf(`
spec:
taskSpec:
steps:
- name: mystep
image: myimage
serviceAccountName: %s
timeout: 1h0m0s
`, config.DefaultServiceAccountValue))

expectedTaskRun.ObjectMeta = taskRunObjectMeta("test-pipeline-run-success-unit-test-task-spec", "foo", "test-pipeline-run-success", "test-pipeline", "unit-test-task-spec", false)
expectedTaskRun.Spec.Resources = &v1beta1.TaskRunResources{}

// ignore IgnoreUnexported ignore both after and before steps fields
if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1beta1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" {
if d := cmp.Diff(expectedTaskRun, actual, ignoreTypeMeta, cmpopts.SortSlices(func(x, y v1beta1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRun, diff.PrintWantGot(d))
}

Expand Down

0 comments on commit f1f0aee

Please sign in to comment.