@@ -22,13 +22,7 @@ func TestCleanupCmd(t *testing.T) {
2222 name : "Missing required service-id" ,
2323 args : []string {"cleanup" },
2424 expectError : true ,
25- errorContains : "required flag(s)" ,
26- },
27- {
28- name : "Missing required script (even though not used for cleanup)" ,
29- args : []string {"cleanup" , "--service-id=test-service" },
30- expectError : true ,
31- errorContains : "required flag(s) \" script\" not set" ,
25+ errorContains : "service-id is required" ,
3226 },
3327 }
3428
@@ -38,9 +32,7 @@ func TestCleanupCmd(t *testing.T) {
3832 cmd := & cobra.Command {Use : "tagit" }
3933 cmd .PersistentFlags ().StringP ("consul-addr" , "c" , "127.0.0.1:8500" , "consul address" )
4034 cmd .PersistentFlags ().StringP ("service-id" , "s" , "" , "consul service id" )
41- cmd .MarkPersistentFlagRequired ("service-id" )
4235 cmd .PersistentFlags ().StringP ("script" , "x" , "" , "path to script used to generate tags" )
43- cmd .MarkPersistentFlagRequired ("script" )
4436 cmd .PersistentFlags ().StringP ("tag-prefix" , "p" , "tagged" , "prefix to be added to tags" )
4537 cmd .PersistentFlags ().StringP ("interval" , "i" , "60s" , "interval to run the script" )
4638 cmd .PersistentFlags ().StringP ("token" , "t" , "" , "consul token" )
@@ -63,8 +55,7 @@ func TestCleanupCmd(t *testing.T) {
6355 if tt .expectError {
6456 assert .Error (t , err )
6557 if tt .errorContains != "" {
66- output := buf .String ()
67- assert .Contains (t , output , tt .errorContains )
58+ assert .Contains (t , err .Error (), tt .errorContains )
6859 }
6960 } else {
7061 assert .NoError (t , err )
@@ -100,7 +91,6 @@ func TestCleanupCmdFlagParsing(t *testing.T) {
10091 cmd .SetArgs ([]string {
10192 "cleanup" ,
10293 "--service-id=test-service" ,
103- "--script=/tmp/test.sh" , // Required by root command
10494 "--tag-prefix=test" ,
10595 "--consul-addr=localhost:8500" ,
10696 "--token=test-token" ,
@@ -179,7 +169,6 @@ func TestCleanupCmdExecution(t *testing.T) {
179169 cmd .SetArgs ([]string {
180170 "cleanup" ,
181171 "--service-id=test-service" ,
182- "--script=/tmp/test.sh" ,
183172 "--consul-addr=" + tt .consulAddr ,
184173 "--tag-prefix=test" ,
185174 })
@@ -229,7 +218,6 @@ func TestCleanupCmdFlagRetrieval(t *testing.T) {
229218 cmd .SetArgs ([]string {
230219 "cleanup" ,
231220 "--service-id=test-service" ,
232- "--script=/tmp/test.sh" ,
233221 "--consul-addr=localhost:9500" ,
234222 "--tag-prefix=test-prefix" ,
235223 "--token=test-token" ,
@@ -285,7 +273,6 @@ func TestCleanupCmdSuccessFlow(t *testing.T) {
285273 cmd .SetArgs ([]string {
286274 "cleanup" ,
287275 "--service-id=test-service" ,
288- "--script=/tmp/test.sh" ,
289276 "--consul-addr=localhost:8500" ,
290277 "--tag-prefix=test" ,
291278 "--token=secret-token" ,
0 commit comments