Skip to content

Commit

Permalink
Merge pull request #187 from MrDXY/replace-test-errors-with-assert-qu…
Browse files Browse the repository at this point in the history
…orum

Test: Replace t.error/fatal with assert/request in [/quorum]
  • Loading branch information
ahrtr authored Mar 21, 2024
2 parents e1bfcf7 + ddfe109 commit a83a3bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions quorum/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/cockroachdb/datadriven"
"github.com/stretchr/testify/require"
)

// TestDataDriven parses and executes the test cases in ./testdata/*. An entry
Expand Down Expand Up @@ -68,9 +69,7 @@ func TestDataDriven(t *testing.T) {
case "cfgj":
joint = true
if arg.Vals[i] == "zero" {
if len(arg.Vals) != 1 {
t.Fatalf("cannot mix 'zero' into configuration")
}
require.Len(t, arg.Vals, 1, "cannot mix 'zero' into configuration")
} else {
var n uint64
arg.Scan(t, i, &n)
Expand All @@ -81,11 +80,9 @@ func TestDataDriven(t *testing.T) {
// Register placeholders as zeroes.
if arg.Vals[i] != "_" {
arg.Scan(t, i, &n)
if n == 0 {
// This is a restriction caused by the above
// special-casing for _.
t.Fatalf("cannot use 0 as idx")
}
// This is a restriction caused by the above
// special-casing for _.
require.NotZero(t, n, "cannot use 0 as idx")
}
idxs = append(idxs, Index(n))
case "votes":
Expand Down
6 changes: 3 additions & 3 deletions quorum/quick_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"reflect"
"testing"
"testing/quick"

"github.com/stretchr/testify/require"
)

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

Expand Down

0 comments on commit a83a3bb

Please sign in to comment.