libcryfs/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp
Sebastian Messmer 449133e3da - Allow callback when fuse filesystem is mounted
- Use that callback to initialize the file system instead of initializing it up front
2018-12-03 01:57:30 -05:00

36 lines
1017 B
C++

#include "testutils/FuseTruncateTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Return;
class FuseTruncateFilenameTest: public FuseTruncateTest {
};
TEST_F(FuseTruncateFilenameTest, TruncateFile) {
ReturnIsFileOnLstat("/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/myfile", fspp::num_bytes_t(0));
}
TEST_F(FuseTruncateFilenameTest, TruncateFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/mydir/myfile", fspp::num_bytes_t(0));
}
TEST_F(FuseTruncateFilenameTest, TruncateFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/mydir2/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/mydir/mydir2/myfile", fspp::num_bytes_t(0));
}