From 8b02ff7cc5b2600d08f5c371c1f51b981e376945 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 18 Dec 2022 17:35:08 +0100 Subject: [PATCH] Improve rename tests --- .../impl/filesystem/CryNodeTest_RenameNested.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/cryfs/impl/filesystem/CryNodeTest_RenameNested.cpp b/test/cryfs/impl/filesystem/CryNodeTest_RenameNested.cpp index 334fbf1d..ec28689b 100644 --- a/test/cryfs/impl/filesystem/CryNodeTest_RenameNested.cpp +++ b/test/cryfs/impl/filesystem/CryNodeTest_RenameNested.cpp @@ -83,7 +83,12 @@ public: void expect_rename_succeeds(const bf::path& source_path, const bf::path& dest_path) { auto source = device().Load(source_path).value(); source->rename(dest_path); - // TODO Test that rename was successful + + // Test that rename was successful + if (source_path != dest_path && source_path != "/") { + ASSERT_FALSE(Exists(source_path)); + } + ASSERT_TRUE(Exists(dest_path)); } void expect_rename_fails(const bf::path& source_path, const bf::path& dest_path, int expected_errno) { @@ -94,7 +99,14 @@ public: } catch (const FuseErrnoException& e) { ASSERT_EQ(expected_errno, e.getErrno()); } - // TODO Test rename wasn't successful + // Test rename wasn't successful + if (dest_path != "/") { + ASSERT_TRUE(Exists(source_path)); + } + auto source_dirs = SourceDirs(); + if (source_path != dest_path && source_path != "/" && std::find(source_dirs.begin(), source_dirs.end(), dest_path) == source_dirs.end()) { + ASSERT_FALSE(Exists(dest_path)); + } } };