@@ -570,3 +570,88 @@ def test_process_first_specific_section_no_usage_footer():
570570 f"--section { section } should not show the usage footer"
571571 )
572572
573+
574+ # -- scaffold arg pass-through (cli.devopsos vs cli.scaffold_*) ------------
575+
576+ def test_scaffold_help_explains_dual_invocation ():
577+ """`devopsos scaffold --help` documents both invocation forms and the difference."""
578+ result = _run (["-m" , "cli.devopsos" , "scaffold" , "--help" ])
579+ assert result .returncode == 0
580+ text = _strip_ansi (result .stdout )
581+ assert "cli.devopsos" in text , "help should mention cli.devopsos"
582+ assert "cli.scaffold_" in text , "help should mention cli.scaffold_* modules"
583+ assert "forwarded" in text .lower () or "forward" in text .lower (), (
584+ "help should mention that extra args are forwarded"
585+ )
586+
587+
588+ def test_scaffold_jenkins_args_forwarded_via_cli ():
589+ """`devopsos scaffold jenkins --type build --languages python` forwards args to scaffold_jenkins."""
590+ with tempfile .TemporaryDirectory () as tmp :
591+ out = os .path .join (tmp , "Jenkinsfile" )
592+ result = subprocess .run (
593+ [
594+ sys .executable , "-m" , "cli.devopsos" ,
595+ "scaffold" , "jenkins" ,
596+ "--type" , "build" ,
597+ "--languages" , "python" ,
598+ "--output" , out ,
599+ ],
600+ capture_output = True , text = True ,
601+ cwd = os .path .dirname (os .path .dirname (__file__ )),
602+ )
603+ assert result .returncode == 0 , result .stderr
604+ assert "error: unrecognized arguments" not in result .stderr
605+ assert os .path .isfile (out ), "Jenkinsfile should have been created"
606+ content = Path (out ).read_text ()
607+ assert "pipeline" in content .lower () or "node" in content .lower (), (
608+ "Jenkinsfile should contain pipeline content"
609+ )
610+
611+
612+ def test_scaffold_gha_args_forwarded_via_cli ():
613+ """`devopsos scaffold gha --type build --name my-app` forwards args to scaffold_gha."""
614+ with tempfile .TemporaryDirectory () as tmp :
615+ out_dir = os .path .join (tmp , ".github" , "workflows" )
616+ result = subprocess .run (
617+ [
618+ sys .executable , "-m" , "cli.devopsos" ,
619+ "scaffold" , "gha" ,
620+ "--type" , "build" ,
621+ "--name" , "my-app" ,
622+ "--output" , out_dir ,
623+ ],
624+ capture_output = True , text = True ,
625+ cwd = os .path .dirname (os .path .dirname (__file__ )),
626+ )
627+ assert result .returncode == 0 , result .stderr
628+ assert "error: unrecognized arguments" not in result .stderr
629+ wf_files = list (Path (out_dir ).glob ("*.yml" ))
630+ assert wf_files , "At least one workflow YAML should have been created"
631+
632+
633+ def test_scaffold_via_cli_matches_direct_module_output ():
634+ """Output from `devopsos scaffold gitlab` equals `python -m cli.scaffold_gitlab` (same defaults)."""
635+ with tempfile .TemporaryDirectory () as tmp1 , tempfile .TemporaryDirectory () as tmp2 :
636+ out1 = os .path .join (tmp1 , ".gitlab-ci.yml" )
637+ out2 = os .path .join (tmp2 , ".gitlab-ci.yml" )
638+
639+ base_args = ["--name" , "test-app" , "--type" , "build" ]
640+
641+ result_unified = subprocess .run (
642+ [sys .executable , "-m" , "cli.devopsos" , "scaffold" , "gitlab" ] + base_args + ["--output" , out1 ],
643+ capture_output = True , text = True ,
644+ cwd = os .path .dirname (os .path .dirname (__file__ )),
645+ )
646+ result_direct = subprocess .run (
647+ [sys .executable , "-m" , "cli.scaffold_gitlab" ] + base_args + ["--output" , out2 ],
648+ capture_output = True , text = True ,
649+ cwd = os .path .dirname (os .path .dirname (__file__ )),
650+ )
651+
652+ assert result_unified .returncode == 0 , result_unified .stderr
653+ assert result_direct .returncode == 0 , result_direct .stderr
654+ assert Path (out1 ).read_text () == Path (out2 ).read_text (), (
655+ "Unified CLI and direct module should produce identical output"
656+ )
657+
0 commit comments