diff options
Diffstat (limited to 'test/behaviour/mounts.zig')
| -rw-r--r-- | test/behaviour/mounts.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/behaviour/mounts.zig b/test/behaviour/mounts.zig new file mode 100644 index 00000000..57685a38 --- /dev/null +++ b/test/behaviour/mounts.zig @@ -0,0 +1,25 @@ +//! docs/typ/reference.typ, Paths and mounts <mounts>. +const std = @import("std"); +const Session = @import("session").Session; +const expectEqual = std.testing.expectEqual; + +fn has(hay: []const u8, needle: []const u8) bool { + return std.mem.indexOf(u8, hay, needle) != null; +} + +test "mounts: Mount with no dial is wrong #args, any other x!y a bad dial address, a socket not there no such socket, and none mounts anything" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try expectEqual(@as(u16, 22), try s.refused("/ctl", "Mount work\n")); + try std.testing.expect(std.mem.startsWith(u8, s.said, "wrong #args")); + try expectEqual(@as(u16, 22), try s.refused("/ctl", "Mount work tcp!nohost\n")); + try std.testing.expect(std.mem.startsWith(u8, s.said, "Mount: bad dial address: tcp!nohost")); + try expectEqual(@as(u16, 2), try s.refused("/ctl", "Mount peer unix!/tmp/pardes-surely-no-socket\n")); + try std.testing.expect(has(s.said, "no such socket")); + try expectEqual(@as(u16, 22), try s.refused("/ctl", "Mount peer rel/x.sock\n")); + // Nothing was mounted under either name. + for ([_][]const u8{ "Unmount work\n", "Unmount peer\n" }) |line| { + try expectEqual(@as(u16, 2), try s.refused("/ctl", line)); + try std.testing.expect(has(s.said, "no such mount")); + } +} |
