Skip to content

Commit a83a3bb

Browse files
authored
Merge pull request #187 from MrDXY/replace-test-errors-with-assert-quorum
Test: Replace t.error/fatal with assert/request in [/quorum]
2 parents e1bfcf7 + ddfe109 commit a83a3bb

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

quorum/datadriven_test.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"github.com/cockroachdb/datadriven"
23+
"github.com/stretchr/testify/require"
2324
)
2425

2526
// TestDataDriven parses and executes the test cases in ./testdata/*. An entry
@@ -68,9 +69,7 @@ func TestDataDriven(t *testing.T) {
6869
case "cfgj":
6970
joint = true
7071
if arg.Vals[i] == "zero" {
71-
if len(arg.Vals) != 1 {
72-
t.Fatalf("cannot mix 'zero' into configuration")
73-
}
72+
require.Len(t, arg.Vals, 1, "cannot mix 'zero' into configuration")
7473
} else {
7574
var n uint64
7675
arg.Scan(t, i, &n)
@@ -81,11 +80,9 @@ func TestDataDriven(t *testing.T) {
8180
// Register placeholders as zeroes.
8281
if arg.Vals[i] != "_" {
8382
arg.Scan(t, i, &n)
84-
if n == 0 {
85-
// This is a restriction caused by the above
86-
// special-casing for _.
87-
t.Fatalf("cannot use 0 as idx")
88-
}
83+
// This is a restriction caused by the above
84+
// special-casing for _.
85+
require.NotZero(t, n, "cannot use 0 as idx")
8986
}
9087
idxs = append(idxs, Index(n))
9188
case "votes":

quorum/quick_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"reflect"
2121
"testing"
2222
"testing/quick"
23+
24+
"github.com/stretchr/testify/require"
2325
)
2426

2527
// TestQuick uses quickcheck to heuristically assert that the main
@@ -37,9 +39,7 @@ func TestQuick(t *testing.T) {
3739
fn2 := func(c memberMap, l idxMap) uint64 {
3840
return uint64(alternativeMajorityCommittedIndex(MajorityConfig(c), mapAckIndexer(l)))
3941
}
40-
if err := quick.CheckEqual(fn1, fn2, cfg); err != nil {
41-
t.Fatal(err)
42-
}
42+
require.NoError(t, quick.CheckEqual(fn1, fn2, cfg))
4343
})
4444
}
4545

0 commit comments

Comments
 (0)