@@ -28,7 +28,7 @@ import (
28
28
29
29
func TestListenersDeleteByID (t * testing.T ) {
30
30
mc := apiclientmocks .NewFFTMClient (t )
31
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
31
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
32
32
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--listener" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" })
33
33
mc .On ("DeleteListener" , mock .Anything , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" ).Return (nil )
34
34
err := cmd .Execute ()
@@ -38,7 +38,7 @@ func TestListenersDeleteByID(t *testing.T) {
38
38
39
39
func TestListenersDeleteByName (t * testing.T ) {
40
40
mc := apiclientmocks .NewFFTMClient (t )
41
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
41
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
42
42
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--name" , "foo" })
43
43
mc .On ("DeleteListenersByName" , mock .Anything , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "foo" ).Return (nil )
44
44
err := cmd .Execute ()
@@ -48,31 +48,31 @@ func TestListenersDeleteByName(t *testing.T) {
48
48
49
49
func TestListenersDeleteNoEventStream (t * testing.T ) {
50
50
mc := apiclientmocks .NewFFTMClient (t )
51
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
51
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
52
52
cmd .SetArgs ([]string {"listeners" , "delete" })
53
53
err := cmd .Execute ()
54
54
assert .Regexp (t , "eventstream flag not set" , err )
55
55
}
56
56
57
57
func TestListenersDeleteNoID (t * testing.T ) {
58
58
mc := apiclientmocks .NewFFTMClient (t )
59
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
59
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
60
60
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" })
61
61
err := cmd .Execute ()
62
62
assert .Regexp (t , "listener or name flag must be set" , err )
63
63
}
64
64
65
65
func TestListenersDeleteIDandName (t * testing.T ) {
66
66
mc := apiclientmocks .NewFFTMClient (t )
67
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
67
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
68
68
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--listener" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" , "--name" , "foo" })
69
69
err := cmd .Execute ()
70
70
assert .Regexp (t , "listener and name flags cannot be combined" , err )
71
71
}
72
72
73
73
func TestListenersDeleteByNameError (t * testing.T ) {
74
74
mc := apiclientmocks .NewFFTMClient (t )
75
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
75
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
76
76
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--name" , "foo" })
77
77
mc .On ("DeleteListenersByName" , mock .Anything , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "foo" ).Return (fmt .Errorf ("pop" ))
78
78
err := cmd .Execute ()
@@ -82,10 +82,19 @@ func TestListenersDeleteByNameError(t *testing.T) {
82
82
83
83
func TestListenersDeleteByIDError (t * testing.T ) {
84
84
mc := apiclientmocks .NewFFTMClient (t )
85
- cmd := buildClientCommand (func () apiclient.FFTMClient { return mc })
85
+ cmd := buildClientCommand (func () ( apiclient.FFTMClient , error ) { return mc , nil })
86
86
cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--listener" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" })
87
87
mc .On ("DeleteListener" , mock .Anything , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" ).Return (fmt .Errorf ("pop" ))
88
88
err := cmd .Execute ()
89
89
assert .Regexp (t , "pop" , err )
90
90
mc .AssertExpectations (t )
91
91
}
92
+
93
+ func TestListenersDeleteByIDBadClientConf (t * testing.T ) {
94
+ mc := apiclientmocks .NewFFTMClient (t )
95
+ cmd := buildClientCommand (func () (apiclient.FFTMClient , error ) { return mc , fmt .Errorf ("pop" ) })
96
+ cmd .SetArgs ([]string {"listeners" , "delete" , "--eventstream" , "f9506df2-5473-4fd4-9cfb-f835656eaaa7" , "--listener" , "7db29758-2a5a-4cc5-91ec-72ade16e0dc5" })
97
+ err := cmd .Execute ()
98
+ assert .Regexp (t , "pop" , err )
99
+ mc .AssertExpectations (t )
100
+ }
0 commit comments