Skip to content

Commit

Permalink
Remove Test Builders from pipelinerunstate_test.go
Browse files Browse the repository at this point in the history
It is better to have simple tests with full objects than test builders as of Issue tektoncd#3178. Since, they are easier to maintain and are easier to read.
  • Loading branch information
popcor255 committed Mar 2, 2021
1 parent ca26ea8 commit 5c42e60
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"github.com/google/go-cmp/cmp"
tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag"
Expand Down Expand Up @@ -1045,7 +1044,12 @@ func TestGetPipelineConditionStatus(t *testing.T) {
}}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
pr := tb.PipelineRun("somepipelinerun")
pr := &v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "somepipelinerun",
},
Spec: v1beta1.PipelineRunSpec{},
}
d, err := dagFromState(tc.state)
if err != nil {
t.Fatalf("Unexpected error while buildig DAG for state %v: %v", tc.state, err)
Expand Down Expand Up @@ -1178,7 +1182,12 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) {

for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
pr := tb.PipelineRun("pipelinerun-final-tasks")
pr := &v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinerun-final-tasks",
},
Spec: v1beta1.PipelineRunSpec{},
}
d, err := dag.Build(v1beta1.PipelineTaskList(tc.dagTasks), v1beta1.PipelineTaskList(tc.dagTasks).Deps())
if err != nil {
t.Fatalf("Unexpected error while buildig graph for DAG tasks %v: %v", tc.dagTasks, err)
Expand Down

0 comments on commit 5c42e60

Please sign in to comment.