summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-08-01 11:56:37 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-08-07 17:01:01 +0200
commitb1aacb171e292cbdcb06f428ec1ca37ed01969c2 (patch)
treed03ecc7c645a069ddf40223e7f1d804bbbf84556 /test
parent2ab4fc7b08b47ca04007a56574bb263a1c7324da (diff)
downloadjustbuild-b1aacb171e292cbdcb06f428ec1ca37ed01969c2.tar.gz
test: Add check for reading objects by path from a Git tree
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/file_system/git_repo.test.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp
index 69ab7e6c..4d8c5b4a 100644
--- a/test/buildtool/file_system/git_repo.test.cpp
+++ b/test/buildtool/file_system/git_repo.test.cpp
@@ -29,6 +29,8 @@ auto const kRootCommit =
std::string{"3ecce3f5b19ad7941c6354d65d841590662f33ef"};
auto const kRootId = std::string{"18770dacfe14c15d88450c21c16668e13ab0e7f9"};
auto const kBazId = std::string{"1868f82682c290f0b1db3cacd092727eef1fa57f"};
+auto const kFooId = std::string{"19102815663d23f8b75a47e7a01965dcdc96468c"};
+auto const kBarId = std::string{"ba0e162e1c47469e3fe4b393a8bf8c569f302116"};
} // namespace
@@ -337,6 +339,36 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
CHECK_FALSE(*result_non_bare);
}
}
+
+ SECTION("Read object from tree by relative path") {
+ SECTION("Non-existing") {
+ auto obj_info =
+ repo->GetObjectByPathFromTree(kRootId, "does_not_exist");
+ CHECK_FALSE(obj_info);
+ }
+ SECTION("File") {
+ auto obj_info = repo->GetObjectByPathFromTree(kRootId, "foo");
+ REQUIRE(obj_info);
+ CHECK(obj_info->id == kFooId);
+ CHECK(obj_info->type == ObjectType::File);
+ CHECK_FALSE(obj_info->symlink_content);
+ }
+ SECTION("Tree") {
+ auto obj_info = repo->GetObjectByPathFromTree(kRootId, "baz");
+ REQUIRE(obj_info);
+ CHECK(obj_info->id == kBazId);
+ CHECK(obj_info->type == ObjectType::Tree);
+ CHECK_FALSE(obj_info->symlink_content);
+ }
+ SECTION("Symlink") {
+ auto obj_info = repo->GetObjectByPathFromTree(kRootId, "baz/bar_l");
+ REQUIRE(obj_info);
+ CHECK(obj_info->id == kBarId);
+ CHECK(obj_info->type == ObjectType::Symlink);
+ CHECK(obj_info->symlink_content);
+ CHECK(*obj_info->symlink_content == "bar");
+ }
+ }
}
TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {