Skip to content

Commit

Permalink
Adds info message after service create and delete operations (#95)
Browse files Browse the repository at this point in the history
* Adds info message after service create operation

 Fixes #87

 Aligns the service delete info message with service create too.

* Updates per review comments

 Adds newline after std imports
 Line breaks at proper operator
  • Loading branch information
navidshaikh authored and knative-prow-robot committed May 14, 2019
1 parent 39034a7 commit 5b8b9d5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/kn/commands/service_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package commands

import (
"errors"
"fmt"

serving_lib "github.com/knative/client/pkg/serving"
servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
Expand Down Expand Up @@ -73,7 +74,7 @@ func NewServiceCreateCommand(p *KnParams) *cobra.Command {
if err != nil {
return err
}

fmt.Fprintf(cmd.OutOrStdout(), "Service '%s' successfully created in namespace '%s'.\n", args[0], namespace)
return nil
},
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/kn/commands/service_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"

servinglib "github.com/knative/client/pkg/serving"
Expand Down Expand Up @@ -66,9 +67,8 @@ func fakeServiceCreate(args []string) (
}

func TestServiceCreateImage(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
action, created, output, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz"})

if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
Expand All @@ -79,6 +79,9 @@ func TestServiceCreateImage(t *testing.T) {
t.Fatal(err)
} else if conf.RevisionTemplate.Spec.Container.Image != "gcr.io/foo/bar:baz" {
t.Fatalf("wrong image set: %v", conf.RevisionTemplate.Spec.Container.Image)
} else if !strings.Contains(output, "foo") || !strings.Contains(output, "created") ||
!strings.Contains(output, "default") {
t.Fatalf("wrong stdout message: %v", output)
}
}

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 @@ -53,7 +53,7 @@ func NewServiceDeleteCommand(p *KnParams) *cobra.Command {
if err != nil {
return err
}
fmt.Fprintf(cmd.OutOrStdout(), "Deleted %s in %s namespace.\n", args[0], namespace)
fmt.Fprintf(cmd.OutOrStdout(), "Service '%s' successfully deleted in namespace '%s'.\n", args[0], namespace)
return nil
},
}
Expand Down

0 comments on commit 5b8b9d5

Please sign in to comment.