Skip to content

Commit 44606c7

Browse files
authored
Merge pull request #24 from JameelB/AEROGEAR-1856
[AEROGEAR-1856] Review command for mobile client creation
2 parents e41fb6c + 0262a1e commit 44606c7

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

pkg/cmd/clients.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,18 @@ func (cc *ClientCmd) CreateClientCmd() *cobra.Command {
105105
cmd := &cobra.Command{
106106
Use: "client <name> <clientType iOS|cordova|android>",
107107
Short: "create a mobile client representation in your namespace",
108-
Long: `Sets up the representation of a mobile application in your namespace. This used to provide a mobile client context for various
109-
actions such as doing mobile client builds,
110-
mobile --namespace=myproject create client <name> <clientType>
111-
kubectl plugin mobile create client <name> <clientType>
112-
oc plugin mobile create client <name> <clientType>
113-
`,
108+
Long: `Sets up the representation of a mobile application of the specified type in your namespace.
109+
This is used to provide a mobile client context for various actions such as creating, starting or stopping mobile client builds.
110+
111+
The available client types are android, cordova and iOS.
112+
113+
When used standalone, a namespace must be specified by providing the --namespace flag.`,
114+
Example: ` mobile create client <name> <clientType> --namespace=myproject
115+
kubectl plugin mobile create client <name> <clientType>
116+
oc plugin mobile create client <name> <clientType>`,
114117
RunE: func(cmd *cobra.Command, args []string) error {
115118
if len(args) != 2 {
116-
return errors.New("expected a name and clientType " + cmd.Use)
119+
return errors.New("expected a name and a clientType")
117120
}
118121
name := args[0]
119122
clientType := args[1]

pkg/cmd/clients_test.go

+5-38
Original file line numberDiff line numberDiff line change
@@ -383,40 +383,6 @@ func TestCreateClient(t *testing.T) {
383383
}
384384
},
385385
},
386-
{
387-
Name: "test create cordova mobile client succeeds without error",
388-
Args: []string{"test", "cordova"},
389-
MobileClient: func() mc.Interface {
390-
mc := &mcFake.Clientset{}
391-
mc.AddReactor("create", "mobileclients", func(action kt.Action) (handled bool, ret runtime.Object, err error) {
392-
ca := action.(kt.CreateAction)
393-
return true, ca.GetObject(), nil
394-
})
395-
return mc
396-
},
397-
Flags: []string{"--namespace=myproject", "-o=json"},
398-
Validate: func(t *testing.T, c *v1alpha1.MobileClient) {
399-
if nil == c {
400-
t.Fatal("expected a mobile client but got nil")
401-
}
402-
if c.Spec.ClientType != "cordova" {
403-
t.Fatal("expected the clientType to be cordova but got ", c.Spec.ClientType)
404-
}
405-
if c.Spec.Name != "test" {
406-
t.Fatal("expected the client name to be test but got ", c.Spec.Name)
407-
}
408-
if c.Spec.ApiKey == "" {
409-
t.Fatal("expected an apiKey to be generated but it was empty")
410-
}
411-
icon, ok := c.Labels["icon"]
412-
if !ok {
413-
t.Fatal("expected an icon to be set but there was none")
414-
}
415-
if icon != "icon-cordova" {
416-
t.Fatal("expected the icon to be icon-cordova but got ", icon)
417-
}
418-
},
419-
},
420386
{
421387
Name: "test create mobile client fails with unknown client type",
422388
Args: []string{"test", "firefox"},
@@ -432,9 +398,10 @@ func TestCreateClient(t *testing.T) {
432398
Flags: []string{"--namespace=myproject", "-o=json"},
433399
},
434400
{
435-
Name: "test create mobile client fails when missing required arguments",
436-
Args: []string{"test"},
437-
ExpectError: true,
401+
Name: "test create mobile client fails when missing required arguments",
402+
Args: []string{"test"},
403+
ExpectError: true,
404+
ErrorPattern: "^expected a name and a clientType",
438405
MobileClient: func() mc.Interface {
439406
mc := &mcFake.Clientset{}
440407
mc.AddReactor("create", "mobileclients", func(action kt.Action) (handled bool, ret runtime.Object, err error) {
@@ -448,7 +415,7 @@ func TestCreateClient(t *testing.T) {
448415
Name: "test create mobile client fails with clear error message",
449416
Args: []string{"test", "cordova"},
450417
ExpectError: true,
451-
ErrorPattern: "^failed to create mobile client:.*",
418+
ErrorPattern: "^failed to create mobile client: something went wrong",
452419
MobileClient: func() mc.Interface {
453420
mc := &mcFake.Clientset{}
454421
mc.AddReactor("create", "mobileclients", func(action kt.Action) (handled bool, ret runtime.Object, err error) {

0 commit comments

Comments
 (0)