@@ -74,6 +74,12 @@ def fake_get_metadata(_tb_path):
7474 return {"pbench" : {"date" : "2002-05-16T00:00:00" }, "run" : {"controller" : "ABC" }}
7575
7676
77+ MEMBER_NOT_FOUND_MSG = b"mock-tar: metadata.log: Not found in mock-archive"
78+ CANNOT_OPEN_MSG = (
79+ b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory"
80+ )
81+
82+
7783class TestCacheManager :
7884 def test_create (self , server_config , make_logger ):
7985 """
@@ -955,25 +961,9 @@ def mock_find_dataset(_self, dataset: str) -> MockTarball:
955961 # Loop/sleep twice, then success
956962 ("/usr/bin/tar" , False , 2 , b"[test]" , None , 0 , b"" ),
957963 # Member path failure
958- (
959- "/usr/bin/tar" ,
960- False ,
961- 0 ,
962- b"" ,
963- 1 ,
964- 1 ,
965- b"mock-tar: metadata.log: Not found in mock-archive" ,
966- ),
964+ ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , MEMBER_NOT_FOUND_MSG ),
967965 # Archive access failure
968- (
969- "/usr/bin/tar" ,
970- False ,
971- 0 ,
972- b"" ,
973- 1 ,
974- 1 ,
975- b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory" ,
976- ),
966+ ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , CANNOT_OPEN_MSG ),
977967 # Unexpected failure
978968 ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , b"mock-tar: bolt out of the blue!" ),
979969 # Hang, never returning output nor an exit code
@@ -1058,6 +1048,7 @@ def mock_shutil_which(
10581048 except CacheExtractBadPath as exc :
10591049 assert tar_path
10601050 assert not popen_fail
1051+ assert stderr_contents == MEMBER_NOT_FOUND_MSG
10611052 assert str (exc ) == f"Unable to extract { path } from { tar .name } "
10621053 except subprocess .TimeoutExpired as exc :
10631054 assert tar_path
@@ -1071,6 +1062,7 @@ def mock_shutil_which(
10711062 else :
10721063 assert not popen_fail
10731064 msg = f"Unexpected error from { tar_path } : { stderr_contents .decode ()!r} "
1065+ assert stderr_contents != MEMBER_NOT_FOUND_MSG
10741066 assert str (exc ) == f"An error occurred while unpacking { tar } : { msg } "
10751067 except ValueError :
10761068 assert tar_path
0 commit comments