Skip to content

Commit

Permalink
fix(service update): Print success message after successful update (k…
Browse files Browse the repository at this point in the history
…native#169)

* fix(service update): Print success message after successful update

* chore(service update): Improve test, revert unneeded changes
  • Loading branch information
rhuss authored and knative-prow-robot committed Jun 17, 2019
1 parent c2be52d commit 8a1d412
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/kn/commands/service/service_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package service

import (
"errors"
"fmt"

"github.com/knative/client/pkg/kn/commands"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,9 +66,11 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command {
return err
}

fmt.Fprintf(cmd.OutOrStdout(), "Service '%s' updated in namespace '%s'.\n", args[0], namespace)
return nil
},
}

commands.AddNamespaceFlags(serviceUpdateCommand.Flags(), false)
editFlags.AddUpdateFlags(serviceUpdateCommand)
return serviceUpdateCommand
Expand Down
13 changes: 11 additions & 2 deletions pkg/kn/commands/service/service_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"

"github.com/knative/client/pkg/kn/commands"
Expand Down Expand Up @@ -73,8 +74,8 @@ func TestServiceUpdateImage(t *testing.T) {

servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")

action, updated, _, err := fakeServiceUpdate(orig, []string{
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy"})
action, updated, output, err := fakeServiceUpdate(orig, []string{
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy", "--namespace", "bar"})

if err != nil {
t.Fatal(err)
Expand All @@ -88,6 +89,14 @@ func TestServiceUpdateImage(t *testing.T) {
} else if template.Spec.DeprecatedContainer.Image != "gcr.io/foo/quux:xyzzy" {
t.Fatalf("wrong image set: %v", template.Spec.DeprecatedContainer.Image)
}

if !strings.Contains(strings.ToLower(output), "update") ||
!strings.Contains(output, "foo") ||
!strings.Contains(strings.ToLower(output), "service") ||
!strings.Contains(strings.ToLower(output), "namespace") ||
!strings.Contains(output, "bar") {
t.Fatalf("wrong or no success message: %s", output)
}
}

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

0 comments on commit 8a1d412

Please sign in to comment.