mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-13 22:37:28 +00:00
fix(mailbox): reject invalid bot toggle values (#80)
Co-authored-by: rissrice2105-agent <rissrice2105-agent@users.noreply.github.com>
This commit is contained in:
parent
ad76e7fa16
commit
ee06082ce1
2 changed files with 43 additions and 1 deletions
|
|
@ -230,3 +230,30 @@ func TestRunBotListRejectsInvalidLimit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunBotFlagSeenRejectInvalidToggle(t *testing.T) {
|
||||
tr := seeded()
|
||||
c := paidClient(tr)
|
||||
|
||||
for _, args := range [][]string{
|
||||
{"flag", Inbox, "1", "maybe"},
|
||||
{"seen", Inbox, "1", "maybe"},
|
||||
} {
|
||||
var out bytes.Buffer
|
||||
err := RunBot(context.Background(), c, args, strings.NewReader(""), &out)
|
||||
if err == nil {
|
||||
t.Fatalf("RunBot(%v) expected error", args)
|
||||
}
|
||||
if !strings.Contains(out.String(), "use on/off") {
|
||||
t.Fatalf("RunBot(%v) output = %q, want on/off error", args, out.String())
|
||||
}
|
||||
}
|
||||
|
||||
msg, ok, err := tr.ReadMessage(context.Background(), Inbox, 1)
|
||||
if err != nil || !ok {
|
||||
t.Fatalf("ReadMessage: ok=%v err=%v", ok, err)
|
||||
}
|
||||
if msg.Flagged || msg.Seen {
|
||||
t.Fatalf("invalid flag/seen toggles should not mutate message: %+v", msg.MessageSummary)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue