@@ -74,6 +74,10 @@ 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 = b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory"
79+
80+
7781class TestCacheManager :
7882 def test_create (self , server_config , make_logger ):
7983 """
@@ -955,25 +959,9 @@ def mock_find_dataset(_self, dataset: str) -> MockTarball:
955959 # Loop/sleep twice, then success
956960 ("/usr/bin/tar" , False , 2 , b"[test]" , None , 0 , b"" ),
957961 # 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- ),
962+ ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , MEMBER_NOT_FOUND_MSG ),
967963 # 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- ),
964+ ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , CANNOT_OPEN_MSG ),
977965 # Unexpected failure
978966 ("/usr/bin/tar" , False , 0 , b"" , 1 , 1 , b"mock-tar: bolt out of the blue!" ),
979967 # Hang, never returning output nor an exit code
@@ -1058,6 +1046,7 @@ def mock_shutil_which(
10581046 except CacheExtractBadPath as exc :
10591047 assert tar_path
10601048 assert not popen_fail
1049+ assert stderr_contents == MEMBER_NOT_FOUND_MSG
10611050 assert str (exc ) == f"Unable to extract { path } from { tar .name } "
10621051 except subprocess .TimeoutExpired as exc :
10631052 assert tar_path
@@ -1071,6 +1060,7 @@ def mock_shutil_which(
10711060 else :
10721061 assert not popen_fail
10731062 msg = f"Unexpected error from { tar_path } : { stderr_contents .decode ()!r} "
1063+ assert stderr_contents != MEMBER_NOT_FOUND_MSG
10741064 assert str (exc ) == f"An error occurred while unpacking { tar } : { msg } "
10751065 except ValueError :
10761066 assert tar_path
0 commit comments