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

Error Message for Using --last with tkn task start -f #556

Merged
merged 1 commit into from
Jan 2, 2020
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
5 changes: 4 additions & 1 deletion pkg/cmd/task/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ like cat,foo,bar
return NameArg(args, p)
}
if opt.Filename == "" {
return errors.New("Either a task name or a --filename parameter must be supplied")
return errors.New("either a task name or a --filename parameter must be supplied")
}
if opt.Filename != "" && opt.Last {
return errors.New("cannot use --last option with --filename option")
}
return nil
},
Expand Down
14 changes: 12 additions & 2 deletions pkg/cmd/task/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,24 @@ func Test_start_invalid_namespace(t *testing.T) {
test.AssertOutput(t, "namespaces \"invalid\" not found", err.Error())
}

func Test_start_has_task_arg(t *testing.T) {
func Test_start_has_no_task_arg(t *testing.T) {
c := Command(&test.Params{})

_, err := test.ExecuteCommand(c, "start", "-n", "ns")
if err == nil {
t.Error("Expecting an error but it's empty")
}
test.AssertOutput(t, "Either a task name or a --filename parameter must be supplied", err.Error())
test.AssertOutput(t, "either a task name or a --filename parameter must be supplied", err.Error())
}

func Test_start_has_filename_arg_with_last(t *testing.T) {
c := Command(&test.Params{})

_, err := test.ExecuteCommand(c, "start", "-n", "ns", "--filename=./testdata/task.yaml", "--last")
if err == nil {
t.Error("Expecting an error but it's empty")
}
test.AssertOutput(t, "cannot use --last option with --filename option", err.Error())
}

func Test_start_has_task_filename(t *testing.T) {
Expand Down