Add test cases for removing nodes
This commit is contained in:
parent
91bf6c3647
commit
7ea08fc2b0
@ -246,6 +246,21 @@ TYPED_TEST_P(FsppDirTest, CreateDir_AlreadyExisting) {
|
||||
);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Remove) {
|
||||
this->CreateDir("/mytestdir");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mytestdir"));
|
||||
this->LoadDir("/mytestdir")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mytestdir"));
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppDirTest, Remove_Nested) {
|
||||
this->CreateDir("/mytestdir");
|
||||
this->CreateDir("/mytestdir/mydir");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mytestdir/mydir"));
|
||||
this->LoadDir("/mytestdir/mydir")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mytestdir/mydir"));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(FsppDirTest,
|
||||
Children_RootDir_Empty,
|
||||
Children_RootDir_OneFile_Directly,
|
||||
@ -270,7 +285,9 @@ REGISTER_TYPED_TEST_CASE_P(FsppDirTest,
|
||||
CreateDir_InNonemptyRoot,
|
||||
CreateDir_InEmptyNestedDir,
|
||||
CreateDir_InNonemptyNestedDir,
|
||||
CreateDir_AlreadyExisting
|
||||
CreateDir_AlreadyExisting,
|
||||
Remove,
|
||||
Remove_Nested
|
||||
);
|
||||
|
||||
|
||||
|
@ -193,6 +193,21 @@ TYPED_TEST_P(FsppFileTest, Utimens_Nested) {
|
||||
this->Test_Utimens(this->file_nested.get());
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppFileTest, Remove) {
|
||||
this->CreateFile("/mytestfile");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mytestfile"));
|
||||
this->LoadFile("/mytestfile")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mytestfile"));
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppFileTest, Remove_Nested) {
|
||||
this->CreateDir("/mytestdir");
|
||||
this->CreateFile("/mytestdir/myfile");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mytestdir/myfile"));
|
||||
this->LoadFile("/mytestdir/myfile")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mytestdir/myfile"));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(FsppFileTest,
|
||||
Open_RDONLY,
|
||||
Open_RDONLY_Nested,
|
||||
@ -219,7 +234,9 @@ REGISTER_TYPED_TEST_CASE_P(FsppFileTest,
|
||||
Chmod,
|
||||
Chmod_Nested,
|
||||
Utimens,
|
||||
Utimens_Nested
|
||||
Utimens_Nested,
|
||||
Remove,
|
||||
Remove_Nested
|
||||
);
|
||||
|
||||
//TODO access
|
||||
|
@ -10,9 +10,6 @@
|
||||
template<class ConcreteFileSystemTestFixture>
|
||||
class FsppSymlinkTest: public FileSystemTest<ConcreteFileSystemTestFixture> {
|
||||
public:
|
||||
void CreateSymlink(const std::string &source, const boost::filesystem::path &target) {
|
||||
this->LoadDir("/")->createSymlink(source, target, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
TYPED_TEST_CASE_P(FsppSymlinkTest);
|
||||
@ -35,19 +32,28 @@ TYPED_TEST_P(FsppSymlinkTest, Read_RelativePath) {
|
||||
EXPECT_EQ("../target", this->LoadSymlink("/mysymlink")->target());
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppSymlinkTest, Delete) {
|
||||
TYPED_TEST_P(FsppSymlinkTest, Remove) {
|
||||
this->CreateSymlink("mysymlink", "/my/symlink/target");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mysymlink"));
|
||||
this->LoadSymlink("/mysymlink")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mysymlink"));
|
||||
}
|
||||
|
||||
TYPED_TEST_P(FsppSymlinkTest, Remove_Nested) {
|
||||
this->CreateDir("/mytestdir");
|
||||
this->CreateSymlink("/mytestdir/mysymlink", "/my/symlink/target");
|
||||
EXPECT_NE(boost::none, this->device->Load("/mytestdir/mysymlink"));
|
||||
this->LoadSymlink("/mytestdir/mysymlink")->remove();
|
||||
EXPECT_EQ(boost::none, this->device->Load("/mytestdir/mysymlink"));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(FsppSymlinkTest,
|
||||
Create_AbsolutePath,
|
||||
Create_RelativePath,
|
||||
Read_AbsolutePath,
|
||||
Read_RelativePath,
|
||||
Delete
|
||||
Remove,
|
||||
Remove_Nested
|
||||
);
|
||||
|
||||
//TODO Other tests?
|
||||
|
@ -69,8 +69,8 @@ public:
|
||||
return this->LoadFile(path);
|
||||
}
|
||||
|
||||
cpputils::unique_ref<fspp::Symlink> CreateSymlink(const boost::filesystem::path &path) {
|
||||
this->LoadDir(path.parent_path())->createSymlink(path.filename().native(), "/my/symlink/target", 0, 0);
|
||||
cpputils::unique_ref<fspp::Symlink> CreateSymlink(const boost::filesystem::path &path, const boost::filesystem::path &target = "/my/symlink/target") {
|
||||
this->LoadDir(path.parent_path())->createSymlink(path.filename().native(), target, 0, 0);
|
||||
return this->LoadSymlink(path);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user