Browse Source

raft: make judge clear

Yicheng Qin 11 years ago
parent
commit
c86f484712
1 changed files with 3 additions and 4 deletions
  1. 3 4
      raft/raft_test.go

+ 3 - 4
raft/raft_test.go

@@ -427,12 +427,11 @@ func TestRecvMsgVote(t *testing.T) {
 		sm.Step(Message{Type: msgVote, From: 1, Index: tt.i, LogTerm: tt.term})
 
 		msgs := sm.Msgs()
-		if len(msgs) != 1 {
-			t.Errorf("#%d: len(msgs) = %d, want 1", i, len(msgs))
+		if g := len(msgs); g != 1 {
+			t.Errorf("#%d: len(msgs) = %d, want 1", i, g)
 			continue
 		}
-		g := msgs[0].Index
-		if g != tt.w {
+		if g := msgs[0].Index; g != tt.w {
 			t.Errorf("#%d, m.Index = %d, want %d", i, g, tt.w)
 		}
 	}