Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for tkn task start --filename #517

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cmd/task/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions pkg/cmd/task/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down