Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Replace t.error/fatal with assert/request in [/quorum] #187

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading