mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-15 08:30:36 +03:00
tests: Fix flake in TestHostNameCollision
This commit is contained in:
parent
a67a9d115b
commit
c57a5acca7
16
host_test.go
16
host_test.go
@ -68,13 +68,7 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
|
|
||||||
// Consume the initial buffer
|
// Consume the initial buffer
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
actual := scanner.Text()
|
actual := stripPrompt(scanner.Text())
|
||||||
if !strings.HasPrefix(actual, "[foo] ") {
|
|
||||||
// FIXME: This is flaky. :/
|
|
||||||
t.Errorf("First client failed to get 'foo' name: %q", actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
actual = stripPrompt(actual)
|
|
||||||
expected := " * foo joined. (Connected: 1)"
|
expected := " * foo joined. (Connected: 1)"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got %q; expected %q", actual, expected)
|
t.Errorf("Got %q; expected %q", actual, expected)
|
||||||
@ -84,7 +78,13 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
done <- struct{}{}
|
done <- struct{}{}
|
||||||
|
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
actual = stripPrompt(scanner.Text())
|
actual = scanner.Text()
|
||||||
|
// This check has to happen second because prompt doesn't always
|
||||||
|
// get set before the first message.
|
||||||
|
if !strings.HasPrefix(actual, "[foo] ") {
|
||||||
|
t.Errorf("First client failed to get 'foo' name: %q", actual)
|
||||||
|
}
|
||||||
|
actual = stripPrompt(actual)
|
||||||
expected = " * Guest1 joined. (Connected: 2)"
|
expected = " * Guest1 joined. (Connected: 2)"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got %q; expected %q", actual, expected)
|
t.Errorf("Got %q; expected %q", actual, expected)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user