From 65eea396621e743654c03957664386afd067681d Mon Sep 17 00:00:00 2001 From: "dr.max" Date: Fri, 3 Apr 2020 13:09:44 -0700 Subject: [PATCH] fix(issue #762): correct error message when updating service * correct message when updating service and passing many names * fix issue with TestServiceUpdateWithMultipleImages running create vs update --- CHANGELOG.adoc | 4 ++++ pkg/kn/commands/service/update.go | 2 +- pkg/kn/commands/service/update_test.go | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 298a26f3be..4fc863cf77 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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) diff --git a/pkg/kn/commands/service/update.go b/pkg/kn/commands/service/update.go index b0589e0a1d..fe82ce232d 100644 --- a/pkg/kn/commands/service/update.go +++ b/pkg/kn/commands/service/update.go @@ -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) diff --git a/pkg/kn/commands/service/update_test.go b/pkg/kn/commands/service/update_test.go index bb48aad86f..e197684c77 100644 --- a/pkg/kn/commands/service/update_test.go +++ b/pkg/kn/commands/service/update_test.go @@ -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()