@@ -324,3 +324,106 @@ JSON
324324 [ " $PEON_EXIT " -eq 0 ]
325325 ! afplay_was_called
326326}
327+
328+ # ============================================================
329+ # --packs (list packs)
330+ # ============================================================
331+
332+ @test " --packs lists all available packs" {
333+ run bash " $PEON_SH " --packs
334+ [ " $status " -eq 0 ]
335+ [[ " $output " == * " peon" * ]]
336+ [[ " $output " == * " sc_kerrigan" * ]]
337+ }
338+
339+ @test " --packs marks the active pack with *" {
340+ run bash " $PEON_SH " --packs
341+ [ " $status " -eq 0 ]
342+ [[ " $output " == * " Orc Peon *" * ]]
343+ # sc_kerrigan should NOT be marked
344+ line=$( echo " $output " | grep " sc_kerrigan" )
345+ [[ " $line " != * " *" * ]]
346+ }
347+
348+ @test " --packs marks correct pack after switch" {
349+ bash " $PEON_SH " --pack sc_kerrigan
350+ run bash " $PEON_SH " --packs
351+ [ " $status " -eq 0 ]
352+ [[ " $output " == * " Sarah Kerrigan (StarCraft) *" * ]]
353+ }
354+
355+ # ============================================================
356+ # --pack <name> (set specific pack)
357+ # ============================================================
358+
359+ @test " --pack <name> switches to valid pack" {
360+ run bash " $PEON_SH " --pack sc_kerrigan
361+ [ " $status " -eq 0 ]
362+ [[ " $output " == * " switched to sc_kerrigan" * ]]
363+ [[ " $output " == * " Sarah Kerrigan" * ]]
364+ # Verify config was updated
365+ active=$( /usr/bin/python3 -c " import json; print(json.load(open('$TEST_DIR /config.json'))['active_pack'])" )
366+ [ " $active " = " sc_kerrigan" ]
367+ }
368+
369+ @test " --pack <name> preserves other config fields" {
370+ bash " $PEON_SH " --pack sc_kerrigan
371+ volume=$( /usr/bin/python3 -c " import json; print(json.load(open('$TEST_DIR /config.json'))['volume'])" )
372+ [ " $volume " = " 0.5" ]
373+ }
374+
375+ @test " --pack <name> errors on nonexistent pack" {
376+ run bash " $PEON_SH " --pack nonexistent
377+ [ " $status " -ne 0 ]
378+ [[ " $output " == * " not found" * ]]
379+ [[ " $output " == * " Available packs" * ]]
380+ }
381+
382+ @test " --pack <name> does not modify config on invalid pack" {
383+ bash " $PEON_SH " --pack nonexistent || true
384+ active=$( /usr/bin/python3 -c " import json; print(json.load(open('$TEST_DIR /config.json'))['active_pack'])" )
385+ [ " $active " = " peon" ]
386+ }
387+
388+ # ============================================================
389+ # --pack (cycle, no argument)
390+ # ============================================================
391+
392+ @test " --pack cycles to next pack alphabetically" {
393+ # Active is peon, next alphabetically is sc_kerrigan
394+ run bash " $PEON_SH " --pack
395+ [ " $status " -eq 0 ]
396+ [[ " $output " == * " switched to sc_kerrigan" * ]]
397+ }
398+
399+ @test " --pack cycle wraps around from last to first" {
400+ # Set to sc_kerrigan (last alphabetically), should wrap to peon
401+ bash " $PEON_SH " --pack sc_kerrigan
402+ run bash " $PEON_SH " --pack
403+ [ " $status " -eq 0 ]
404+ [[ " $output " == * " switched to peon" * ]]
405+ }
406+
407+ @test " --pack cycle updates config correctly" {
408+ bash " $PEON_SH " --pack
409+ active=$( /usr/bin/python3 -c " import json; print(json.load(open('$TEST_DIR /config.json'))['active_pack'])" )
410+ [ " $active " = " sc_kerrigan" ]
411+ }
412+
413+ # ============================================================
414+ # --help (updated)
415+ # ============================================================
416+
417+ @test " --help shows pack commands" {
418+ run bash " $PEON_SH " --help
419+ [ " $status " -eq 0 ]
420+ [[ " $output " == * " --packs" * ]]
421+ [[ " $output " == * " --pack" * ]]
422+ }
423+
424+ @test " unknown option shows helpful error" {
425+ run bash " $PEON_SH " --foobar
426+ [ " $status " -ne 0 ]
427+ [[ " $output " == * " Unknown option" * ]]
428+ [[ " $output " == * " peon --help" * ]]
429+ }
0 commit comments