Skip to content

Commit

Permalink
[daemon][unit test] Fix tests expected path on Windows and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sploder12 committed Sep 14, 2024
1 parent e352056 commit 607afba
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/test_vm_mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,33 @@ TEST_F(TestVMMount, notSymlinkSourcePathUnchanged)

TEST_F(TestVMMount, absoluteSymlinkSourcePathResolved)
{
auto source_path = mp::fs::weakly_canonical("/tmp/src");
auto symlink_path = mp::fs::weakly_canonical("/home/dest");

const auto [mock_file_ops, _] = mpt::MockFileOps::inject();
EXPECT_CALL(*mock_file_ops, symlink_status).WillOnce(Return(mp::fs::file_status{mp::fs::file_type::symlink}));
EXPECT_CALL(*mock_file_ops, read_symlink).WillOnce(Return(mp::fs::path{"/home/dest"}));
EXPECT_CALL(*mock_file_ops, read_symlink).WillOnce(Return(symlink_path));

mp::VMMount mount{"/tmp/src", {}, {}, mp::VMMount::MountType::Classic};
mp::VMMount mount{source_path.string(), {}, {}, mp::VMMount::MountType::Classic};

mount.resolve_source_path();

EXPECT_EQ(mount.get_source_path(), "/home/dest");
EXPECT_EQ(mount.get_source_path(), symlink_path.string());
}

TEST_F(TestVMMount, relativeSymlinkSourcePathResolved)
{
auto source_path = mp::fs::weakly_canonical("/tmp/src");

const auto [mock_file_ops, _] = mpt::MockFileOps::inject();
EXPECT_CALL(*mock_file_ops, symlink_status).WillOnce(Return(mp::fs::file_status{mp::fs::file_type::symlink}));
EXPECT_CALL(*mock_file_ops, read_symlink).WillOnce(Return(mp::fs::path{"./dest"}));

mp::VMMount mount{"/tmp/src", {}, {}, mp::VMMount::MountType::Classic};
mp::VMMount mount{source_path.string(), {}, {}, mp::VMMount::MountType::Classic};

mount.resolve_source_path();

EXPECT_EQ(mount.get_source_path(), "/tmp/dest");
EXPECT_EQ(mount.get_source_path(), source_path.replace_filename("dest").string());
}

} // namespace

0 comments on commit 607afba

Please sign in to comment.