Fix more silly race conditions in tests

This commit is contained in:
Andrey Petrov 2016-07-11 13:02:34 -04:00
parent cc6ab7fc90
commit 2b8c0d7b5c
1 changed files with 6 additions and 3 deletions

View File

@ -184,10 +184,13 @@ func TestHostKick(t *testing.T) {
go func() { go func() {
// First client // First client
err = sshd.ConnectShell(addr, "foo", func(r io.Reader, w io.WriteCloser) { err := sshd.ConnectShell(addr, "foo", func(r io.Reader, w io.WriteCloser) {
// Make op // Make op
member, _ := host.Room.MemberById("foo") member, _ := host.Room.MemberById("foo")
member.Op = true if member == nil {
t.Fatal("failed to load MemberById")
}
host.Room.Ops.Add(member)
// Block until second client is here // Block until second client is here
connected <- struct{}{} connected <- struct{}{}
@ -200,7 +203,7 @@ func TestHostKick(t *testing.T) {
go func() { go func() {
// Second client // Second client
err = sshd.ConnectShell(addr, "bar", func(r io.Reader, w io.WriteCloser) { err := sshd.ConnectShell(addr, "bar", func(r io.Reader, w io.WriteCloser) {
<-connected <-connected
// Consume while we're connected. Should break when kicked. // Consume while we're connected. Should break when kicked.