Skip to content

Commit

Permalink
Adds info message after service create operation
Browse files Browse the repository at this point in the history
 Fixes knative#87

 Aligns the service delete info message with service create too.
  • Loading branch information
navidshaikh committed May 10, 2019
1 parent b6d1bb4 commit cf56084
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/kn/commands/service_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package commands

import (
"errors"

"fmt"
serving_lib "github.com/knative/client/pkg/serving"
servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -73,7 +73,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, "default") || !strings.
Contains(output, "created") {
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 cf56084

Please sign in to comment.