2014-11-28 17:40:54 +01:00
|
|
|
#include "testutils/FuseRenameTest.h"
|
|
|
|
|
2019-10-13 17:49:57 +02:00
|
|
|
using ::testing::Eq;
|
2014-11-28 17:40:54 +01:00
|
|
|
using ::testing::Return;
|
|
|
|
|
|
|
|
class FuseRenameFilenameTest: public FuseRenameTest {
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileRootToRoot) {
|
|
|
|
ReturnIsFileOnLstat("/myfile");
|
|
|
|
ReturnDoesntExistOnLstat("/myrenamedfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myfile"), Eq("/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myfile", "/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileRootToNested) {
|
|
|
|
ReturnIsFileOnLstat("/myfile");
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir/myrenamedfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myfile"), Eq("/mydir/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myfile", "/mydir/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileNestedToRoot) {
|
|
|
|
ReturnDoesntExistOnLstat("/myrenamedfile");
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsFileOnLstat("/mydir/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir/myfile", "/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsFileOnLstat("/mydir/myfile");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir/myrenamedfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/mydir/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir/myfile", "/mydir/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested2) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsDirOnLstat("/mydir/mydir2");
|
|
|
|
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir/mydir2/myrenamedfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/mydir2/myfile"), Eq("/mydir/mydir2/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir/mydir2/myfile", "/mydir/mydir2/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested_DifferentFolder) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsDirOnLstat("/mydir2");
|
|
|
|
ReturnIsFileOnLstat("/mydir/myfile");
|
|
|
|
ReturnDoesntExistOnLstat("/mydir2/myrenamedfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/mydir2/myrenamedfile")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir/myfile", "/mydir2/myrenamedfile");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirRootToRoot) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/myrenameddir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir"), Eq("/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir", "/myrenameddir");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirRootToNested) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir");
|
|
|
|
ReturnDoesntExistOnLstat("/myrootdir/myrenameddir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/mydir"), Eq("/myrootdir/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/mydir", "/myrootdir/myrenameddir");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirNestedToRoot) {
|
|
|
|
ReturnDoesntExistOnLstat("/myrenameddir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir/mydir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myrootdir/mydir", "/myrenameddir");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested) {
|
|
|
|
ReturnIsDirOnLstat("/myrootdir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/myrootdir/myrenameddir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrootdir/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myrootdir/mydir", "/myrootdir/myrenameddir");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested2) {
|
|
|
|
ReturnIsDirOnLstat("/myrootdir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir/myrootdir2");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir/myrootdir2/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/myrootdir/myrootdir2/myrenameddir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/myrootdir2/mydir"), Eq("/myrootdir/myrootdir2/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myrootdir/myrootdir2/mydir", "/myrootdir/myrootdir2/myrenameddir");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested_DifferentFolder) {
|
|
|
|
ReturnIsDirOnLstat("/myrootdir");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir2");
|
|
|
|
ReturnIsDirOnLstat("/myrootdir/mydir");
|
|
|
|
ReturnDoesntExistOnLstat("/myrootdir2/myrenameddir");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrootdir2/myrenameddir")))
|
2014-11-28 17:40:54 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
|
|
|
Rename("/myrootdir/mydir", "/myrootdir2/myrenameddir");
|
|
|
|
}
|