Adds info message after service create and delete operations (#95)

* 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
This commit is contained in:
Navid Shaikh 2019-05-14 23:14:41 +05:30 committed by Knative Prow Robot
parent 39034a73f9
commit 5b8b9d53bc
3 changed files with 8 additions and 4 deletions

View File

@ -16,6 +16,7 @@ package commands
import ( import (
"errors" "errors"
"fmt"
serving_lib "github.com/knative/client/pkg/serving" serving_lib "github.com/knative/client/pkg/serving"
servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1" servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
@ -73,7 +74,7 @@ func NewServiceCreateCommand(p *KnParams) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(cmd.OutOrStdout(), "Service '%s' successfully created in namespace '%s'.\n", args[0], namespace)
return nil return nil
}, },
} }

View File

@ -19,6 +19,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"reflect" "reflect"
"strings"
"testing" "testing"
servinglib "github.com/knative/client/pkg/serving" servinglib "github.com/knative/client/pkg/serving"
@ -66,9 +67,8 @@ func fakeServiceCreate(args []string) (
} }
func TestServiceCreateImage(t *testing.T) { 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"}) "service", "create", "foo", "--image", "gcr.io/foo/bar:baz"})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if !action.Matches("create", "services") { } else if !action.Matches("create", "services") {
@ -79,6 +79,9 @@ func TestServiceCreateImage(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} else if conf.RevisionTemplate.Spec.Container.Image != "gcr.io/foo/bar:baz" { } else if conf.RevisionTemplate.Spec.Container.Image != "gcr.io/foo/bar:baz" {
t.Fatalf("wrong image set: %v", conf.RevisionTemplate.Spec.Container.Image) 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)
} }
} }

View File

@ -53,7 +53,7 @@ func NewServiceDeleteCommand(p *KnParams) *cobra.Command {
if err != nil { if err != nil {
return err 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 return nil
}, },
} }