leadership: Fix data races in tests.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-06-12 14:18:37 -07:00
parent 3ee1c37ba3
commit 2b9165b2f2
2 changed files with 1 additions and 2 deletions

View File

@ -27,7 +27,6 @@ func TestCandidate(t *testing.T) {
electedCh := candidate.ElectedCh() electedCh := candidate.ElectedCh()
// Should issue a false upon start, no matter what. // Should issue a false upon start, no matter what.
assert.False(t, candidate.IsLeader())
assert.False(t, <-electedCh) assert.False(t, <-electedCh)
// Since the lock always succeeeds, we should get elected. // Since the lock always succeeeds, we should get elected.

View File

@ -32,9 +32,9 @@ func TestFollower(t *testing.T) {
// We shouldn't see duplicate events. // We shouldn't see duplicate events.
assert.Equal(t, <-leaderCh, "leader1") assert.Equal(t, <-leaderCh, "leader1")
assert.Equal(t, follower.Leader(), "leader1")
assert.Equal(t, <-leaderCh, "leader2") assert.Equal(t, <-leaderCh, "leader2")
assert.Equal(t, <-leaderCh, "leader1") assert.Equal(t, <-leaderCh, "leader1")
assert.Equal(t, follower.Leader(), "leader1")
// Once stopped, iteration over the leader channel should stop. // Once stopped, iteration over the leader channel should stop.
follower.Stop() follower.Stop()