@@ -9,23 +9,17 @@ func TestStopCommand_Validation(t *testing.T) {
99
1010 tests := []commandTestCase {
1111 {
12- name : "stop with no daemon running " ,
12+ name : "stop without program " ,
1313 args : []string {"stop" },
1414 expectedExit : 1 ,
15- shouldContain : "meeseeks server not running" ,
16- },
17- {
18- name : "stop specific program with no daemon" ,
19- args : []string {"stop" , "test-program" },
20- expectedExit : 1 ,
21- shouldContain : "meeseeks server not running" ,
15+ shouldContain : "program name required" ,
2216 },
2317 }
2418
2519 runCommandTests (t , tests )
2620}
2721
28- func TestStopCommand (t * testing.T ) {
22+ func TestStopCommand_MissingProgramName (t * testing.T ) {
2923 configContent := `programs:
3024 - name: "test-stop-program1"
3125 command: "sleep"
@@ -39,22 +33,28 @@ func TestStopCommand(t *testing.T) {
3933
4034 tests := []commandTestCase {
4135 {
42- name : "stop specific program - not implemented " ,
43- args : []string {"stop" , "test-stop-program1" },
36+ name : "stop with invalid timeout " ,
37+ args : []string {"stop" , "-timeout" , "invalid" , " test-stop-program1" },
4438 expectedExit : 1 ,
45- shouldContain : "stop command not yet implemented " ,
39+ shouldContain : "invalid duration " ,
4640 },
4741 {
48- name : "stop non-existing program - not implemented " ,
42+ name : "stop non-existing program" ,
4943 args : []string {"stop" , "fake-program" },
5044 expectedExit : 1 ,
51- shouldContain : "stop command not yet implemented " ,
45+ shouldContain : "program fake-program not present " ,
5246 },
5347 {
54- name : "stop all programs - not implemented" ,
55- args : []string {"stop" },
56- expectedExit : 1 ,
57- shouldContain : "stop command not yet implemented" ,
48+ name : "stop existing program" ,
49+ args : []string {"stop" , "test-stop-program1" },
50+ expectedExit : 0 ,
51+ shouldContain : "test-stop-program1 stopped" ,
52+ },
53+ {
54+ name : "stop with custom timeout" ,
55+ args : []string {"stop" , "-timeout" , "10s" , "test-stop-program2" },
56+ expectedExit : 0 ,
57+ shouldContain : "test-stop-program2 stopped" ,
5858 },
5959 }
6060
@@ -63,7 +63,8 @@ func TestStopCommand(t *testing.T) {
6363
6464func TestStopCommand_Help (t * testing.T ) {
6565 testCommandHelp (t , "stop" , []string {
66- "Usage: meeseeks stop [program_name]" ,
66+ "Usage: meeseeks stop [options] [ program_name]" ,
6767 "Stop running programs" ,
68+ "-timeout" ,
6869 })
6970}
0 commit comments