commit 1eddc1737c959e187070a7ddd470e8c2d22ac46d (tree)
parent a136890accfc3b269b6eaa9139bae829ef36cc6b
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 6 Jan 2026 16:21:39 -0800
std: add test coverage for Io.File.Atomic.link
Diffstat:
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig
@@ -1651,6 +1651,21 @@ test "AtomicFile" {
\\ this is a test file
;
+ // link() succeeds with no file already present
+ {
+ var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false });
+ defer af.deinit(io);
+ try af.file.writeStreamingAll(io, test_content);
+ try af.link(io);
+ }
+ // link() returns error.PathAlreadyExists if file already present
+ {
+ var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false });
+ defer af.deinit(io);
+ try af.file.writeStreamingAll(io, test_content);
+ try expectError(error.PathAlreadyExists, af.link(io));
+ }
+ // replace() succeeds if file already present
{
var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = true });
defer af.deinit(io);