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(service update): Print success message after successful update #169

Merged
merged 2 commits into from
Jun 17, 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: 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 @@ -93,8 +94,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 @@ -108,6 +109,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 TestServiceUpdateEnv(t *testing.T) {
Expand Down