Skip to content

Commit 4989834

Browse files
committed
Use assert in TestSnapshot tests
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent 6cebf97 commit 4989834

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

server/etcdserver/server_test.go

+6-21
Original file line numberDiff line numberDiff line change
@@ -667,24 +667,14 @@ func TestSnapshotDisk(t *testing.T) {
667667
gaction, _ := p.Wait(2)
668668
defer func() { ch <- struct{}{} }()
669669

670-
if len(gaction) != 2 {
671-
t.Errorf("len(action) = %d, want 2", len(gaction))
672-
return
673-
}
674-
if !reflect.DeepEqual(gaction[0], testutil.Action{Name: "SaveSnap"}) {
675-
t.Errorf("action = %s, want SaveSnap", gaction[0])
676-
}
677-
678-
if !reflect.DeepEqual(gaction[1], testutil.Action{Name: "Release"}) {
679-
t.Errorf("action = %s, want Release", gaction[1])
680-
}
670+
assert.Len(t, gaction, 2)
671+
assert.Equal(t, testutil.Action{Name: "SaveSnap"}, gaction[0])
672+
assert.Equal(t, testutil.Action{Name: "Release"}, gaction[1])
681673
}()
682674
ep := etcdProgress{appliedi: 1, confState: raftpb.ConfState{Voters: []uint64{1}}}
683675
srv.snapshot(&ep, true)
684676
<-ch
685-
if len(st.Action()) != 0 {
686-
t.Errorf("no action expected on v2store. Got %d actions", len(st.Action()))
687-
}
677+
assert.Empty(t, st.Action())
688678
assert.Equal(t, uint64(1), ep.diskSnapshotIndex)
689679
assert.Equal(t, uint64(1), ep.memorySnapshotIndex)
690680
}
@@ -728,17 +718,12 @@ func TestSnapshotMemory(t *testing.T) {
728718
gaction, _ := p.Wait(1)
729719
defer func() { ch <- struct{}{} }()
730720

731-
if len(gaction) != 0 {
732-
t.Errorf("len(action) = %d, want 0", len(gaction))
733-
return
734-
}
721+
assert.Empty(t, gaction)
735722
}()
736723
ep := etcdProgress{appliedi: 1, confState: raftpb.ConfState{Voters: []uint64{1}}}
737724
srv.snapshot(&ep, false)
738725
<-ch
739-
if len(st.Action()) != 0 {
740-
t.Errorf("no action expected on v2store. Got %d actions", len(st.Action()))
741-
}
726+
assert.Empty(t, st.Action())
742727
assert.Equal(t, uint64(0), ep.diskSnapshotIndex)
743728
assert.Equal(t, uint64(1), ep.memorySnapshotIndex)
744729
}

0 commit comments

Comments
 (0)