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:
Oliver Graff 2017-06-14 06:07:24 -07:00 committed by Andrey Petrov
parent a631215f5b
commit 05597b3e6a
3 changed files with 7 additions and 3 deletions

View File

@ -71,7 +71,7 @@ func TestHostNameCollision(t *testing.T) {
// Consume the initial buffer
scanner.Scan()
actual := stripPrompt(scanner.Text())
expected := " * foo joined. (Connected: 1)"
expected := " * foo joined. (Connected: 1)\r"
if 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)
}
actual = stripPrompt(actual)
expected = " * Guest1 joined. (Connected: 2)"
expected = " * Guest1 joined. (Connected: 2)\r"
if actual != expected {
t.Errorf("Got %q; expected %q", actual, expected)
}
@ -97,6 +97,7 @@ func TestHostNameCollision(t *testing.T) {
return nil
})
if err != nil {
done <- struct{}{}
t.Fatal(err)
}
}()
@ -203,6 +204,7 @@ func TestHostKick(t *testing.T) {
return nil
})
if err != nil {
connected <- struct{}{}
close(connected)
t.Fatal(err)
}
@ -218,6 +220,7 @@ func TestHostKick(t *testing.T) {
return nil
})
if err != nil {
close(done)
t.Fatal(err)
}
close(done)

View File

@ -26,6 +26,7 @@ func NewClientConfig(name string) *ssh.ClientConfig {
return
}),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
}

View File

@ -52,7 +52,7 @@ func TestServeTerminals(t *testing.T) {
if err != nil {
t.Error(err)
}
_, err = term.Write([]byte("echo: " + line + "\r\n"))
_, err = term.Write([]byte("echo: " + line + "\n"))
if err != nil {
t.Error(err)
}