From 74540c75dd22d8747cdb61846ab636d8e966438d Mon Sep 17 00:00:00 2001 From: Daniel Helfand Date: Thu, 12 Dec 2019 09:57:21 -0500 Subject: [PATCH] test for tkn task start --filename --- pkg/cmd/task/start.go | 3 +-- pkg/cmd/task/start_test.go | 14 +++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/task/start.go b/pkg/cmd/task/start.go index e48143911..b8f2e6a1a 100644 --- a/pkg/cmd/task/start.go +++ b/pkg/cmd/task/start.go @@ -146,8 +146,7 @@ like cat,foo,bar return c } -// Setting as var for stubbing in tests -var parseTask = func(p string) (*v1alpha1.Task, error) { +func parseTask(p string) (*v1alpha1.Task, error) { b, err := ioutil.ReadFile(p) if err != nil { return nil, err diff --git a/pkg/cmd/task/start_test.go b/pkg/cmd/task/start_test.go index 4157f3d3d..0a108ca44 100644 --- a/pkg/cmd/task/start_test.go +++ b/pkg/cmd/task/start_test.go @@ -111,17 +111,13 @@ func Test_start_has_task_filename(t *testing.T) { cs, _ := test.SeedTestData(t, pipelinetest.Data{Namespaces: ns}) c := Command(&test.Params{Tekton: cs.Pipeline, Kube: cs.Kube}) - oldParseTask := parseTask - defer func() { - parseTask = oldParseTask - }() - parseTask = func(p string) (*v1alpha1.Task, error) { - return tb.Task("task", "ns"), nil - } - _, err := test.ExecuteCommand(c, "start", "-n", "ns", "--filename=foo", "--showlog=false") + got, err := test.ExecuteCommand(c, "start", "-n", "ns", "--filename=./testdata/task.yaml", "--showlog=false") if err != nil { - t.Errorf("Not expecting an error, but got %s", err) + t.Errorf("Not expecting an error, but got %s", err.Error()) } + + expected := "Taskrun started: \n\nIn order to track the taskrun progress run:\ntkn taskrun logs -f -n ns\n" + test.AssertOutput(t, expected, got) } func Test_start_task_not_found(t *testing.T) {