@@ -663,3 +663,39 @@ def test_sync_ndjson_machine_output(
663663 event .get ("status" ) for event in events if event ["reason" ] == "sync"
664664 }
665665 assert preview_statuses == {"preview" }
666+
667+
668+ def test_sync_json_machine_output (
669+ tmp_path : pathlib .Path ,
670+ capsys : pytest .CaptureFixture [str ],
671+ monkeypatch : pytest .MonkeyPatch ,
672+ user_path : pathlib .Path ,
673+ config_path : pathlib .Path ,
674+ git_repo : GitSync ,
675+ ) -> None :
676+ """JSON mode should emit a single array without progress chatter."""
677+ config = {
678+ "~/github_projects/" : {
679+ "my_git_repo" : {
680+ "url" : f"git+file://{ git_repo .path } " ,
681+ "remotes" : {"origin" : f"git+file://{ git_repo .path } " },
682+ },
683+ },
684+ }
685+ yaml_config = config_path / ".vcspull.yaml"
686+ yaml_config .write_text (
687+ yaml .dump (config , default_flow_style = False ), encoding = "utf-8"
688+ )
689+
690+ monkeypatch .chdir (tmp_path )
691+
692+ with contextlib .suppress (SystemExit ):
693+ cli (["sync" , "--json" , "--dry-run" , "my_git_repo" ])
694+
695+ captured = capsys .readouterr ()
696+ payload = captured .out .strip ()
697+ assert payload .startswith ("[" ) and payload .endswith ("]" ), payload
698+ events = json .loads (payload )
699+ assert isinstance (events , list )
700+ reasons = {event ["reason" ] for event in events }
701+ assert reasons >= {"sync" , "summary" }
0 commit comments