Skip to content

Commit 2939214

Browse files
author
Aaron
committed
Create motd tests for OP
1 parent 0297c1a commit 2939214

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

host_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,34 @@ func TestMotdCommand(t *testing.T) {
181181
if strings.Compare(host.motd, "foobar") != 0 {
182182
t.Error("failed to hinder non-OPs to modify the MOTD")
183183
}
184+
185+
// Test as OP - expected behaviour: should modify the MOTD
186+
host.Room.Ops.Add(member)
187+
testMotd = "barfoo"
188+
w.Write([]byte("/motd barfoo\r\n"))
189+
190+
// Fix this during the code-review process
191+
time.Sleep(time.Millisecond * 500)
192+
193+
if strings.Compare(host.motd, testMotd) != 0 {
194+
t.Error("failed to allow OPs to modify the MOTD")
195+
}
196+
197+
// Get around rate limitation
198+
time.Sleep(time.Second * 3)
199+
200+
// Test as OP - expected behaviour: should print the MOTD even if OP
201+
w.Write([]byte("/motd\r\n"))
202+
203+
nextScanToken(scanner, 8)
204+
205+
actual = scanner.Text()
206+
actual = stripPrompt(actual)[3:]
207+
expected = "barfoo"
208+
if strings.Compare(actual, expected) != 0 {
209+
t.Error("failed to print MOTD using /motd with no parameters - as OP")
210+
}
211+
184212
return nil
185213
})
186214
}

0 commit comments

Comments
 (0)