2014-11-25 18:04:59 +01:00
|
|
|
#include "testutils/FuseTruncateTest.h"
|
|
|
|
|
|
|
|
using ::testing::_;
|
2019-10-13 17:49:57 +02:00
|
|
|
using ::testing::Eq;
|
2014-11-25 18:04:59 +01:00
|
|
|
using ::testing::Return;
|
|
|
|
|
|
|
|
class FuseTruncateFilenameTest: public FuseTruncateTest {
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(FuseTruncateFilenameTest, TruncateFile) {
|
|
|
|
ReturnIsFileOnLstat("/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, truncate(Eq("/myfile"), _))
|
2014-11-25 18:04:59 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
2018-09-15 23:32:58 +02:00
|
|
|
TruncateFile("/myfile", fspp::num_bytes_t(0));
|
2014-11-25 18:04:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseTruncateFilenameTest, TruncateFileNested) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsFileOnLstat("/mydir/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, truncate(Eq("/mydir/myfile"), _))
|
2014-11-25 18:04:59 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
2018-09-15 23:32:58 +02:00
|
|
|
TruncateFile("/mydir/myfile", fspp::num_bytes_t(0));
|
2014-11-25 18:04:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FuseTruncateFilenameTest, TruncateFileNested2) {
|
|
|
|
ReturnIsDirOnLstat("/mydir");
|
|
|
|
ReturnIsDirOnLstat("/mydir/mydir2");
|
|
|
|
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
|
2019-10-13 17:49:57 +02:00
|
|
|
EXPECT_CALL(*fsimpl, truncate(Eq("/mydir/mydir2/myfile"), _))
|
2014-11-25 18:04:59 +01:00
|
|
|
.Times(1).WillOnce(Return());
|
|
|
|
|
2018-09-15 23:32:58 +02:00
|
|
|
TruncateFile("/mydir/mydir2/myfile", fspp::num_bytes_t(0));
|
2014-11-25 18:04:59 +01:00
|
|
|
}
|