authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-06 16:21:39-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 11:03:37-08:00
log1eddc1737c959e187070a7ddd470e8c2d22ac46d
treed4860223684ba867909fa98051105ed653508b6b
parenta136890accfc3b269b6eaa9139bae829ef36cc6b

std: add test coverage for Io.File.Atomic.link


1 files changed, 15 insertions(+), 0 deletions(-)

lib/std/fs/test.zig+15
...@@ -1651,6 +1651,21 @@ test "AtomicFile" {...@@ -1651,6 +1651,21 @@ test "AtomicFile" {
1651 \\ this is a test file1651 \\ this is a test file
1652 ;1652 ;
16531653
1654 // link() succeeds with no file already present
1655 {
1656 var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false });
1657 defer af.deinit(io);
1658 try af.file.writeStreamingAll(io, test_content);
1659 try af.link(io);
1660 }
1661 // link() returns error.PathAlreadyExists if file already present
1662 {
1663 var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false });
1664 defer af.deinit(io);
1665 try af.file.writeStreamingAll(io, test_content);
1666 try expectError(error.PathAlreadyExists, af.link(io));
1667 }
1668 // replace() succeeds if file already present
1654 {1669 {
1655 var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = true });1670 var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = true });
1656 defer af.deinit(io);1671 defer af.deinit(io);