Commit 78019452f7

Ryan Liptak <squeek502@hotmail.com>
2021-05-24 01:35:31
Add updateFile to . and .. fs tests
1 parent 1bc0df7
Changed files (1)
lib
std
lib/std/fs/test.zig
@@ -954,6 +954,10 @@ test ". and .. in fs.Dir functions" {
     renamed_file.close();
     try tmp.dir.deleteFile("./subdir/../rename");
 
+    try tmp.dir.writeFile("./subdir/../update", "something");
+    const prev_status = try tmp.dir.updateFile("./subdir/../file", tmp.dir, "./subdir/../update", .{});
+    try testing.expectEqual(fs.PrevStatus.stale, prev_status);
+
     try tmp.dir.deleteDir("./subdir");
 }
 
@@ -991,5 +995,12 @@ test ". and .. in absolute functions" {
     renamed_file.close();
     try fs.deleteFileAbsolute(renamed_file_path);
 
+    const update_file_path = try fs.path.join(allocator, &[_][]const u8{ subdir_path, "../update" });
+    const update_file = try fs.createFileAbsolute(update_file_path, .{});
+    try update_file.writeAll("something");
+    update_file.close();
+    const prev_status = try fs.updateFileAbsolute(created_file_path, update_file_path, .{});
+    try testing.expectEqual(fs.PrevStatus.stale, prev_status);
+
     try fs.deleteDirAbsolute(subdir_path);
 }