mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 15:47:17 +03:00
Fix unit tests / Travis (#238)
* Fix net_test * Update host test to add carriage return char * Fix host_test so it will not hang if the SSH connection fails Fixes #231, closes #235.
This commit is contained in:
parent
a631215f5b
commit
05597b3e6a
@ -71,7 +71,7 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
// Consume the initial buffer
|
// Consume the initial buffer
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
actual := stripPrompt(scanner.Text())
|
actual := stripPrompt(scanner.Text())
|
||||||
expected := " * foo joined. (Connected: 1)"
|
expected := " * foo joined. (Connected: 1)\r"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got %q; expected %q", actual, expected)
|
t.Errorf("Got %q; expected %q", actual, expected)
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
t.Errorf("First client failed to get 'foo' name: %q", actual)
|
t.Errorf("First client failed to get 'foo' name: %q", actual)
|
||||||
}
|
}
|
||||||
actual = stripPrompt(actual)
|
actual = stripPrompt(actual)
|
||||||
expected = " * Guest1 joined. (Connected: 2)"
|
expected = " * Guest1 joined. (Connected: 2)\r"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got %q; expected %q", actual, expected)
|
t.Errorf("Got %q; expected %q", actual, expected)
|
||||||
}
|
}
|
||||||
@ -97,6 +97,7 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
done <- struct{}{}
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -203,6 +204,7 @@ func TestHostKick(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
connected <- struct{}{}
|
||||||
close(connected)
|
close(connected)
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -218,6 +220,7 @@ func TestHostKick(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
close(done)
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
close(done)
|
close(done)
|
||||||
|
@ -26,6 +26,7 @@ func NewClientConfig(name string) *ssh.ClientConfig {
|
|||||||
return
|
return
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ func TestServeTerminals(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
_, err = term.Write([]byte("echo: " + line + "\r\n"))
|
_, err = term.Write([]byte("echo: " + line + "\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user