diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-05-24 14:23:05 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-05-31 15:21:02 +0200 |
commit | a563be278f9ef4b928701e6c708726ba6252a213 (patch) | |
tree | f7cbcc32ef99f5c83bf3c3a7a25e96adbda40218 /test/buildtool/file_system/file_root.test.cpp | |
parent | bc93b16bf6eccf23d7018444872867f97f5dc94d (diff) | |
download | justbuild-a563be278f9ef4b928701e6c708726ba6252a213.tar.gz |
test: Streamline filesystem git test repo...
...by removing unused subfolders and corresponding redundant checks
in the tests using it. Also fixes misues in tests of the GetSubtree
family of methods.
Diffstat (limited to 'test/buildtool/file_system/file_root.test.cpp')
-rw-r--r-- | test/buildtool/file_system/file_root.test.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp index 1255a263..e00ca6cc 100644 --- a/test/buildtool/file_system/file_root.test.cpp +++ b/test/buildtool/file_system/file_root.test.cpp @@ -25,7 +25,7 @@ namespace { auto const kBundlePath = std::string{"test/buildtool/file_system/data/test_repo.bundle"}; -auto const kTreeId = std::string{"e51a219a27b672ccf17abec7d61eb4d6e0424140"}; +auto const kTreeId = std::string{"c610db170fbcad5f2d66fe19972495923f3b2536"}; auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"}; auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"}; @@ -68,7 +68,7 @@ void TestFileRootReadFile(FileRoot const& root) { CHECK(*bar == "bar"); REQUIRE(root.Exists("baz")); - CHECK_FALSE(root.IsFile("baz")); + REQUIRE(root.IsDirectory("baz")); } void TestFileRootReadEntries(FileRoot const& root, @@ -89,8 +89,7 @@ void TestFileRootReadEntries(FileRoot const& root, void TestFileRootReadDirectory(FileRoot const& root) { TestFileRootReadEntries(root, ".", true); - TestFileRootReadEntries(root, "baz", true); - TestFileRootReadEntries(root, "baz/baz", false); + TestFileRootReadEntries(root, "baz", false); } void TestFileRootReadFileType(FileRoot const& root) { @@ -98,12 +97,25 @@ void TestFileRootReadFileType(FileRoot const& root) { REQUIRE(foo_type); CHECK(*foo_type == ObjectType::File); - auto bar_type = root.FileType("baz/baz/bar"); + auto bar_type = root.FileType("baz/bar"); REQUIRE(bar_type); CHECK(*bar_type == ObjectType::Executable); CHECK_FALSE(root.FileType("baz")); CHECK_FALSE(root.FileType("does_not_exist")); + + // Check subdir + REQUIRE(root.Exists("baz/foo")); + REQUIRE(root.IsFile("baz/foo")); + auto bazfoo = root.ReadFile("baz/foo"); + REQUIRE(bazfoo); + CHECK(*bazfoo == "foo"); + + REQUIRE(root.Exists("baz/bar")); + REQUIRE(root.IsFile("baz/bar")); + auto bazbar = root.ReadFile("baz/bar"); + REQUIRE(bazbar); + CHECK(*bazbar == "bar"); } } // namespace @@ -232,7 +244,7 @@ TEST_CASE("Creating artifact descriptions", "[file_root]") { ObjectType::File, "repo"}); - auto bar = root->ToArtifactDescription("baz/baz/bar", "repo"); + auto bar = root->ToArtifactDescription("baz/bar", "repo"); REQUIRE(bar); CHECK(*bar == ArtifactDescription{ArtifactDigest{kBarId, 3, /*is_tree=*/false}, |