Skip to content

Commit 0262a1e

Browse files
committed
review create client tests
1 parent 1acfb40 commit 0262a1e

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

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)