test(bot): record recursive substitution test case
Found while the IRC users tried to find bugs in the code base.
Currently the bot does not "hear" the commands of users, which means
that of the following conversation:
```
<jassob> helo, world!
<jassob> s/helo/hello/
```
the only heard messages in the backlog would be the first ("helo,
world!"), the substitution would be parsed and executed, but not added
to the backlog and hence not possible to update.
This commit is contained in:
parent
b0f0daa19d
commit
4f2b9cbce2
1 changed files with 30 additions and 0 deletions
30
src/bot.zig
30
src/bot.zig
|
|
@ -297,3 +297,33 @@ test "execute substitution with no matching needle" {
|
|||
"#test",
|
||||
));
|
||||
}
|
||||
|
||||
test "recursive substitutions does not cause issues" {
|
||||
var bot = try Bot.init(std.testing.allocator);
|
||||
defer bot.deinit();
|
||||
|
||||
// hear original message
|
||||
const msg = try newTestMessage(std.testing.allocator, "original");
|
||||
bot.hear(msg);
|
||||
|
||||
// execute substitution
|
||||
const cmd = UserCommand.init_substitute("jassob", "original", "something else", false);
|
||||
switch (try bot.execute(
|
||||
&cmd,
|
||||
null,
|
||||
"#test",
|
||||
)) {
|
||||
.PRIVMSG => |message| {
|
||||
try std.testing.expectEqualDeep("jassob: \"something else\"", message.text);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
|
||||
// execute second substitution
|
||||
const cmd2 = UserCommand.init_substitute("jassob", "s/original/something else/", "something else", false);
|
||||
try std.testing.expectError(Error.NoMessage, bot.execute(
|
||||
&cmd2,
|
||||
null,
|
||||
"#test",
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue