File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -70,5 +70,6 @@ def test_format_report_data_structure(generator: PostgresReportGenerator) -> Non
7070 payload = generator .format_report_data ("A002" , {"foo" : "bar" }, host )
7171
7272 assert payload ["checkId" ] == "A002"
73- assert payload ["hosts" ]["master" ] == host
73+ # Newer reporter returns a 'nodes' structure instead of legacy 'hosts'.
74+ assert payload ["nodes" ]["primary" ] == host
7475 assert payload ["results" ][host ]["data" ] == {"foo" : "bar" }
Original file line number Diff line number Diff line change @@ -784,6 +784,11 @@ class DummyGenerator:
784784 def __init__ (self , * args , ** kwargs ):
785785 self .closed = False
786786
787+ def get_all_clusters (self ):
788+ # Match current reporter.main() behavior which always calls
789+ # get_all_clusters() when cluster is not explicitly provided.
790+ return ["local" ]
791+
787792 def test_connection (self ) -> bool :
788793 return True
789794
@@ -799,7 +804,19 @@ def close_postgres_sink(self):
799804 postgres_reports_module .main ()
800805
801806 captured = capsys .readouterr ().out
802- output = json .loads (captured )
807+
808+ # main() prints progress banners along with the JSON payload.
809+ # Extract the JSON object from the captured stdout by finding the
810+ # first line that looks like JSON and joining from there.
811+ lines = captured .splitlines ()
812+ start_idx = 0
813+ for i , line in enumerate (lines ):
814+ if line .strip ().startswith ("{" ):
815+ start_idx = i
816+ break
817+ json_str = "\n " .join (lines [start_idx :])
818+
819+ output = json .loads (json_str )
803820 assert output ["checkId" ] == "A002"
804821 assert "results" in output
805822
You can’t perform that action at this time.
0 commit comments