mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-09 20:28:29 -04:00
hopefully make test less racy
This commit is contained in:
parent
20720ae2c4
commit
dbc0bdbeac
14
host_test.go
14
host_test.go
@ -238,13 +238,17 @@ func TestHostAllowlistCommand(t *testing.T) {
|
|||||||
scanner.Scan() // Joined
|
scanner.Scan() // Joined
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
|
|
||||||
assertLineEq := func(expected string) {
|
assertLineEq := func(expected ...string) {
|
||||||
if !scanner.Scan() {
|
if !scanner.Scan() {
|
||||||
t.Error("no line available")
|
t.Error("no line available")
|
||||||
}
|
}
|
||||||
if actual := stripPrompt(scanner.Text()); actual != expected {
|
actual := stripPrompt(scanner.Text())
|
||||||
t.Errorf("expected %q, got %q", expected, actual)
|
for _, exp := range expected {
|
||||||
|
if exp == actual {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
t.Errorf("expected %#v, got %q", expected, actual)
|
||||||
}
|
}
|
||||||
sendCmd := func(cmd string, formatting ...interface{}) {
|
sendCmd := func(cmd string, formatting ...interface{}) {
|
||||||
host.HandleMsg(message.ParseInput(fmt.Sprintf(cmd, formatting...), m.User))
|
host.HandleMsg(message.ParseInput(fmt.Sprintf(cmd, formatting...), m.User))
|
||||||
@ -321,9 +325,9 @@ func TestHostAllowlistCommand(t *testing.T) {
|
|||||||
assertLineEq("allowlist is disabled, so nobody will be kicked\r")
|
assertLineEq("allowlist is disabled, so nobody will be kicked\r")
|
||||||
sendCmd("/allowlist on")
|
sendCmd("/allowlist on")
|
||||||
sendCmd("/allowlist reverify")
|
sendCmd("/allowlist reverify")
|
||||||
|
assertLineEq(" * [bar] were kicked during pubkey reverification.\r", " * bar left. (After 0 seconds)\r")
|
||||||
|
assertLineEq(" * [bar] were kicked during pubkey reverification.\r", " * bar left. (After 0 seconds)\r")
|
||||||
kickSignal <- struct{}{}
|
kickSignal <- struct{}{}
|
||||||
assertLineEq(" * [bar] were kicked during pubkey reverification.\r")
|
|
||||||
assertLineEq(" * bar left. (After 0 seconds)\r")
|
|
||||||
|
|
||||||
sendCmd("/allowlist add " + testKey)
|
sendCmd("/allowlist add " + testKey)
|
||||||
sendCmd("/allowlist status")
|
sendCmd("/allowlist status")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user