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

fix(issue #762): correct error message when updating service #778

Merged
merged 3 commits into from
Apr 7, 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
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
| Fix plugin lookup with file ext on Windows
| https://github.com/knative/client/pull/774[#774]

| 🐛
| Correct error message when updating service
| https://github.com/knative/client/pull/778[#778]

|===

## v0.13.1 (2020-03-25)
Expand Down
7 changes: 7 additions & 0 deletions pkg/kn/commands/service/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func TestServiceCreateWithMultipleImages(t *testing.T) {
assert.Assert(t, util.ContainsAll(err.Error(), "\"--image\"", "\"gcr.io/bar/foo:baz\"", "flag", "once"))
}

func TestServiceCreateWithMultipleNames(t *testing.T) {
_, _, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "foo1", "--image", "gcr.io/foo/bar:baz", "--no-wait"}, false)

assert.Assert(t, util.ContainsAll(err.Error(), "'service create' requires the service name given as single argument"))
}

func TestServiceCreateImageSync(t *testing.T) {
action, created, output, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz"}, false)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewServiceDeleteCommand(p *commands.KnParams) *cobra.Command {

RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("requires the service name")
return errors.New("'service delete' requires the service name(s)")
}

namespace, err := p.GetNamespace(cmd)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {
Short: "Show details of a service",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("'kn service describe' requires name of the service as single argument")
return errors.New("'service describe' requires the service name given as single argument")
}
serviceName := args[0]

Expand Down
10 changes: 10 additions & 0 deletions pkg/kn/commands/service/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ func TestServiceDescribeBasic(t *testing.T) {
r.Validate()
}

func TestServiceDescribeWithMultipleNames(t *testing.T) {
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()
createTestService("foo", []string{"rev1"}, goodConditions())
_, err := executeServiceCommand(client, "describe", "foo", "foo1")

assert.Assert(t, util.ContainsAll(err.Error(), "'service describe' requires the service name given as single argument"))
r.Validate()
}

func TestServiceDescribeSad(t *testing.T) {
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command {
Example: updateExample,
RunE: func(cmd *cobra.Command, args []string) (err error) {
if len(args) != 1 {
return errors.New("requires the service name")
return errors.New("'service update' requires the service name given as single argument")
}

namespace, err := p.GetNamespace(cmd)
Expand Down
10 changes: 9 additions & 1 deletion pkg/kn/commands/service/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,19 @@ func TestServiceUpdateImage(t *testing.T) {
func TestServiceUpdateWithMultipleImages(t *testing.T) {
orig := newEmptyService()
_, _, _, err := fakeServiceUpdate(orig, []string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--image", "gcr.io/bar/foo:baz", "--no-wait"})
"service", "update", "foo", "--image", "gcr.io/foo/bar:baz", "--image", "gcr.io/bar/foo:baz", "--no-wait"})

assert.Assert(t, util.ContainsAll(err.Error(), "\"--image\"", "\"gcr.io/bar/foo:baz\"", "flag", "once"))
}

func TestServiceUpdateWithMultipleNames(t *testing.T) {
orig := newEmptyService()
_, _, _, err := fakeServiceUpdate(orig, []string{
"service", "update", "foo", "foo1", "--image", "gcr.io/foo/bar:baz", "--no-wait"})

assert.Assert(t, util.ContainsAll(err.Error(), "'service update' requires the service name given as single argument"))
}

func TestServiceUpdateCommand(t *testing.T) {
orig := newEmptyService()

Expand Down