refactor(commands): move user command tests
This commit just shuffles the test for user commands closer to the definition of the user commands.
This commit is contained in:
parent
958c00ce6f
commit
49a6b79fd9
1 changed files with 31 additions and 31 deletions
|
|
@ -53,6 +53,37 @@ pub const UserCommand = union(enum) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test "can parse !help successful" {
|
||||||
|
try std.testing.expectEqual(
|
||||||
|
UserCommand.help,
|
||||||
|
UserCommand.parse("jassob", "!help"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "can parse s/hello/world/ successful" {
|
||||||
|
try std.testing.expectEqualDeep(
|
||||||
|
UserCommand{ .substitute = .{
|
||||||
|
.author = "jassob",
|
||||||
|
.needle = "hello",
|
||||||
|
.replacement = "world",
|
||||||
|
.all = false,
|
||||||
|
} },
|
||||||
|
UserCommand.parse("jassob", "s/hello/world/"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
test "can parse s/hello/world and report failure" {
|
||||||
|
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "s/hello/world"));
|
||||||
|
}
|
||||||
|
|
||||||
|
test "can parse s/hello|world| and report failure" {
|
||||||
|
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "s/hello/world"));
|
||||||
|
}
|
||||||
|
|
||||||
|
test "correctly ignores non-messages when trying to parse" {
|
||||||
|
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "Hello, world"));
|
||||||
|
}
|
||||||
|
|
||||||
/// AdminCommand are commands useful for debugging zigeru, since they
|
/// AdminCommand are commands useful for debugging zigeru, since they
|
||||||
/// are more spammy than others they are separated and only sent to
|
/// are more spammy than others they are separated and only sent to
|
||||||
/// #eru-admin.
|
/// #eru-admin.
|
||||||
|
|
@ -91,37 +122,6 @@ pub const AdminCommand = union(enum) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
test "can parse !help successful" {
|
|
||||||
try std.testing.expectEqual(
|
|
||||||
UserCommand.help,
|
|
||||||
UserCommand.parse("jassob", "!help"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
test "can parse s/hello/world/ successful" {
|
|
||||||
try std.testing.expectEqualDeep(
|
|
||||||
UserCommand{ .substitute = .{
|
|
||||||
.author = "jassob",
|
|
||||||
.needle = "hello",
|
|
||||||
.replacement = "world",
|
|
||||||
.all = false,
|
|
||||||
} },
|
|
||||||
UserCommand.parse("jassob", "s/hello/world/"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
test "can parse s/hello/world and report failure" {
|
|
||||||
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "s/hello/world"));
|
|
||||||
}
|
|
||||||
|
|
||||||
test "can parse s/hello|world| and report failure" {
|
|
||||||
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "s/hello/world"));
|
|
||||||
}
|
|
||||||
|
|
||||||
test "correctly ignores non-messages when trying to parse" {
|
|
||||||
try std.testing.expectEqualDeep(null, UserCommand.parse("jassob", "Hello, world"));
|
|
||||||
}
|
|
||||||
|
|
||||||
test "parse admin commands" {
|
test "parse admin commands" {
|
||||||
const cmd = AdminCommand.parse("!join badchannel") orelse unreachable;
|
const cmd = AdminCommand.parse("!join badchannel") orelse unreachable;
|
||||||
try std.testing.expectEqual(
|
try std.testing.expectEqual(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue