Skip to content

Commit 7801945

Browse files
committed
Add updateFile to . and .. fs tests
1 parent 1bc0df7 commit 7801945

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/std/fs/test.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,10 @@ test ". and .. in fs.Dir functions" {
954954
renamed_file.close();
955955
try tmp.dir.deleteFile("./subdir/../rename");
956956

957+
try tmp.dir.writeFile("./subdir/../update", "something");
958+
const prev_status = try tmp.dir.updateFile("./subdir/../file", tmp.dir, "./subdir/../update", .{});
959+
try testing.expectEqual(fs.PrevStatus.stale, prev_status);
960+
957961
try tmp.dir.deleteDir("./subdir");
958962
}
959963

@@ -991,5 +995,12 @@ test ". and .. in absolute functions" {
991995
renamed_file.close();
992996
try fs.deleteFileAbsolute(renamed_file_path);
993997

998+
const update_file_path = try fs.path.join(allocator, &[_][]const u8{ subdir_path, "../update" });
999+
const update_file = try fs.createFileAbsolute(update_file_path, .{});
1000+
try update_file.writeAll("something");
1001+
update_file.close();
1002+
const prev_status = try fs.updateFileAbsolute(created_file_path, update_file_path, .{});
1003+
try testing.expectEqual(fs.PrevStatus.stale, prev_status);
1004+
9941005
try fs.deleteDirAbsolute(subdir_path);
9951006
}

0 commit comments

Comments
 (0)