Parcourir la source

raft: make judge clear

Yicheng Qin il y a 11 ans
Parent
commit
c86f484712
1 fichiers modifiés avec 3 ajouts et 4 suppressions
  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)
 		}
 	}