Skip to content

Commit

Permalink
fixes pipelinerun desribe test
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishin authored and tekton-robot committed Aug 21, 2019
1 parent 83ae7aa commit 1a1d7a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
9 changes: 4 additions & 5 deletions pkg/cmd/pipelineresource/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import (
"testing"

"github.com/tektoncd/cli/pkg/test"
tu "github.com/tektoncd/cli/pkg/test"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
pipelinetest "github.com/tektoncd/pipeline/test"
tb "github.com/tektoncd/pipeline/test/builder"
)

func TestPipelineResourceDelete_Empty(t *testing.T) {
cs, _ := pipelinetest.SeedTestData(t, pipelinetest.Data{})
cs, _ := test.SeedTestData(t, pipelinetest.Data{})
p := &test.Params{Tekton: cs.Pipeline}

res := Command(p)
Expand All @@ -34,7 +33,7 @@ func TestPipelineResourceDelete_Empty(t *testing.T) {
t.Errorf("Error expected here")
}
expected := "Failed to delete pipelineresource \"bar\": pipelineresources.tekton.dev \"bar\" not found"
tu.AssertOutput(t, expected, err.Error())
test.AssertOutput(t, expected, err.Error())
}

func TestPipelineResourceDelete_WithParams(t *testing.T) {
Expand All @@ -46,10 +45,10 @@ func TestPipelineResourceDelete_WithParams(t *testing.T) {
),
}

cs, _ := pipelinetest.SeedTestData(t, pipelinetest.Data{PipelineResources: pres})
cs, _ := test.SeedTestData(t, pipelinetest.Data{PipelineResources: pres})
p := &test.Params{Tekton: cs.Pipeline}
pipelineresource := Command(p)
out, _ := test.ExecuteCommand(pipelineresource, "rm", "test-1", "-n", "test-ns-1")
expected := "PipelineResource deleted: test-1\n"
tu.AssertOutput(t, expected, out)
test.AssertOutput(t, expected, out)
}
17 changes: 7 additions & 10 deletions pkg/cmd/pipelinerun/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/jonboulle/clockwork"
"github.com/tektoncd/cli/pkg/test"
cb "github.com/tektoncd/cli/pkg/test/builder"
Expand Down Expand Up @@ -150,7 +149,7 @@ func TestPipelineRunDescribe_multiple_taskrun_ordering(t *testing.T) {
}),
tb.PipelineRunTaskRunsStatus("tr-2", &v1alpha1.PipelineRunTaskRunStatus{
PipelineTaskName: "t-2",
Status: &trs[0].Status,
Status: &trs[1].Status,
}),
tb.PipelineRunStatusCondition(apis.Condition{
Status: corev1.ConditionTrue,
Expand All @@ -165,7 +164,7 @@ func TestPipelineRunDescribe_multiple_taskrun_ordering(t *testing.T) {

p := &test.Params{Tekton: cs.Pipeline, Clock: clock}
pipelinerun := Command(p)
clock.Advance(9 * time.Minute)
clock.Advance(10 * time.Minute)
actual, err := test.ExecuteCommand(pipelinerun, "desc", "pipeline-run", "-n", "ns")
if err != nil {
t.Errorf("Unexpected error: %v", err)
Expand All @@ -175,8 +174,8 @@ Namespace: ns
Pipeline Ref: pipeline
Status
STARTED DURATION STATUS
9 minutes ago 15 minutes Succeeded
STARTED DURATION STATUS
10 minutes ago 15 minutes Succeeded
Resources
No resources
Expand All @@ -186,12 +185,10 @@ No params
Taskruns
NAME TASK NAME STARTED DURATION STATUS
tr-2 t-2 7 minutes ago 3 minutes Succeeded
tr-1 t-1 7 minutes ago 3 minutes Succeeded
tr-2 t-2 5 minutes ago 4 minutes Succeeded
tr-1 t-1 8 minutes ago 3 minutes Succeeded
`
if d := cmp.Diff(expected, actual); d != "" {
t.Errorf("Unexpected output mismatch: %s", d)
}
test.AssertOutput(t, expected, actual)

}

Expand Down

0 comments on commit 1a1d7a5

Please sign in to comment.