@@ -79,6 +79,29 @@ def test_list_json(archivers, request):
7979 assert file1 ["sha256" ] == "b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b"
8080
8181
82+ def test_list_json_lines_includes_archive_keys_in_format (archivers , request ):
83+ # Issue #9095 / PR #9096: archivename/archiveid should be available in JSON lines when
84+ # requested via --format.
85+ archiver = request .getfixturevalue (archivers )
86+ create_regular_file (archiver .input_path , "file1" , size = 1024 )
87+ cmd (archiver , "repo-create" , RK_ENCRYPTION )
88+ cmd (archiver , "create" , "test" , "input" )
89+
90+ # Query archive info to obtain expected name and id
91+ info_archive = json .loads (cmd (archiver , "info" , "--json" , "-a" , "test" ))
92+ assert len (info_archive ["archives" ]) == 1
93+ archive_info = info_archive ["archives" ][0 ]
94+ expected_name = archive_info ["name" ]
95+ expected_id = archive_info ["id" ]
96+
97+ out = cmd (archiver , "list" , "test" , "--json-lines" , "--format={archivename} {archiveid}" )
98+ rows = [json .loads (s ) for s in out .splitlines () if s ]
99+ assert len (rows ) >= 2 # directory + file
100+ row = rows [- 1 ]
101+ assert row ["archivename" ] == expected_name
102+ assert row ["archiveid" ] == expected_id
103+
104+
82105def test_list_depth (archivers , request ):
83106 """Test the --depth option for the list command."""
84107 archiver = request .getfixturevalue (archivers )
0 commit comments