raft: add tests for IsLocalMsg (#6357)

* raft: add tests for IsLocalMsg

* report index of failed tests
This commit is contained in:
goroutine 2016-09-06 22:52:37 -05:00 committed by Gyu-Ho Lee
parent b24527f2f0
commit ce49fb6ec4

View File

@ -70,3 +70,35 @@ func TestLimitSize(t *testing.T) {
}
}
}
func TestIsLocalMsg(t *testing.T) {
tests := []struct {
msgt pb.MessageType
isLocal bool
}{
{pb.MsgHup, true},
{pb.MsgBeat, true},
{pb.MsgUnreachable, true},
{pb.MsgSnapStatus, true},
{pb.MsgCheckQuorum, true},
{pb.MsgTransferLeader, false},
{pb.MsgProp, false},
{pb.MsgApp, false},
{pb.MsgAppResp, false},
{pb.MsgVote, false},
{pb.MsgVoteResp, false},
{pb.MsgSnap, false},
{pb.MsgHeartbeat, false},
{pb.MsgHeartbeatResp, false},
{pb.MsgTimeoutNow, false},
{pb.MsgReadIndex, false},
{pb.MsgReadIndexResp, false},
}
for i, tt := range tests {
got := IsLocalMsg(tt.msgt)
if got != tt.isLocal {
t.Errorf("#%d: got %v, want %v", i, got, tt.isLocal)
}
}
}