Skip to content

Commit

Permalink
Avoid a race condition in the timing of the xmpp test
Browse files Browse the repository at this point in the history
  • Loading branch information
olabini committed Aug 25, 2017
1 parent e1ef835 commit 3fdc147
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xmpp/xmpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"log"
"testing"
"time"

"github.com/twstrike/coyim/i18n"
"github.com/twstrike/coyim/xmpp/data"
Expand Down Expand Up @@ -100,6 +101,11 @@ func (s *XMPPSuite) TestConnClose_sendsAStreamCloseTagWhenWeCloseFirst(c *C) {

done := make(chan bool)
go func() {
// This is sadly necessary, since the call to conn.Next() needs to happen AFTER the first few lines of conn.Close()
// has executed. Otherwise there will be a racecondition where conn.Close() sometimes will report that
// the connection has already been executed.
time.Sleep(time.Duration(2) * time.Second)

stanza, err := conn.Next() // Reads the closing tag

c.Assert(err, IsNil)
Expand Down

0 comments on commit 3fdc147

Please sign in to comment.