Merge pull request #6541 from hhkbp2/improve-test-coverage

raft: add test cases to improve test coverage
release-3.1
Xiang Li 2016-09-27 23:24:52 -05:00 committed by GitHub
commit 3807faeddf
2 changed files with 17 additions and 8 deletions

View File

@ -156,6 +156,11 @@ func TestUnstableMaybeTerm(t *testing.T) {
4,
true, 1,
},
{
[]pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
3,
false, 0,
},
{
[]pb.Entry{}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
5,

View File

@ -1434,10 +1434,12 @@ func TestReadOnlyOptionSafe(t *testing.T) {
wri uint64
wctx []byte
}{
{b, 10, 11, []byte("ctx1")},
{c, 10, 21, []byte("ctx2")},
{b, 10, 31, []byte("ctx3")},
{c, 10, 41, []byte("ctx4")},
{a, 10, 11, []byte("ctx1")},
{b, 10, 21, []byte("ctx2")},
{c, 10, 31, []byte("ctx3")},
{a, 10, 41, []byte("ctx4")},
{b, 10, 51, []byte("ctx5")},
{c, 10, 61, []byte("ctx6")},
}
for i, tt := range tests {
@ -1492,10 +1494,12 @@ func TestReadOnlyOptionLease(t *testing.T) {
wri uint64
wctx []byte
}{
{b, 10, 11, []byte("ctx1")},
{c, 10, 21, []byte("ctx2")},
{b, 10, 31, []byte("ctx3")},
{c, 10, 41, []byte("ctx4")},
{a, 10, 11, []byte("ctx1")},
{b, 10, 21, []byte("ctx2")},
{c, 10, 31, []byte("ctx3")},
{a, 10, 41, []byte("ctx4")},
{b, 10, 51, []byte("ctx5")},
{c, 10, 61, []byte("ctx6")},
}
for i, tt := range tests {