aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test_vfs_file_ops.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_vfs_file_ops.cpp')
-rw-r--r--src/tests/test_vfs_file_ops.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tests/test_vfs_file_ops.cpp b/src/tests/test_vfs_file_ops.cpp
index 32b82d2..d923c41 100644
--- a/src/tests/test_vfs_file_ops.cpp
+++ b/src/tests/test_vfs_file_ops.cpp
@@ -81,6 +81,28 @@ TEST(VfsFileOps, CopyOnWriteFromFdCanCopyBackingSourceToDifferentDestination)
EXPECT_EQ(readText(staging / "Plugin.esp"), "saved plugin");
}
+TEST(VfsFileOps, CreateFileReturnsWritableStagingHandle)
+{
+ TempRoot tmp;
+ ASSERT_FALSE(tmp.path().empty());
+
+ const fs::path staging = tmp.path() / "staging";
+ const fs::path overwrite = tmp.path() / "overwrite";
+
+ OverwriteManager overwriteManager(staging.string(), overwrite.string());
+ std::string realPath;
+ const int fd = overwriteManager.createFile("ShaderCache/Lighting/test.pso",
+ 0600, &realPath);
+ ASSERT_GE(fd, 0);
+
+ const char payload[] = "shader";
+ ASSERT_EQ(write(fd, payload, sizeof(payload) - 1), ssize_t(sizeof(payload) - 1));
+ close(fd);
+
+ EXPECT_EQ(fs::path(realPath), staging / "ShaderCache/Lighting/test.pso");
+ EXPECT_EQ(readText(realPath), "shader");
+}
+
TEST(VfsFileOps, InodeRenameMovesDescendants)
{
InodeTable table;