Skip to content

Commit 308fcc2

Browse files
committed
fix: tests assertions
1 parent e4818c8 commit 308fcc2

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

tests/merkle_single_missing_key_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/stretchr/testify/assert"
9+
810
"github.com/hyp3rd/hypercache/pkg/backend"
911
cache "github.com/hyp3rd/hypercache/pkg/cache/v2"
1012
)
@@ -57,9 +59,8 @@ func TestMerkleSingleMissingKey(t *testing.T) {
5759
}
5860

5961
got, _ := db.Get(ctx, "k1")
60-
if got == nil {
61-
t.Fatalf("expected key pulled")
62-
}
62+
63+
assert.NotNil(t, got, "expected key pulled")
6364

6465
if bs, ok := got.Value.([]byte); !ok || string(bs) != "v1" {
6566
t.Fatalf("unexpected value %v", got.Value)

tests/merkle_sync_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/stretchr/testify/assert"
9+
810
"github.com/hyp3rd/hypercache/pkg/backend"
911
cache "github.com/hyp3rd/hypercache/pkg/cache/v2"
1012
)
@@ -42,9 +44,9 @@ func TestMerkleSyncConvergence(t *testing.T) {
4244
itA, _ := dmA.Get(ctx, k)
4345

4446
itB, _ := dmB.Get(ctx, k)
45-
if itA == nil || itB == nil {
46-
t.Fatalf("missing key %s after sync", k)
47-
}
47+
48+
assert.NotNil(t, itA, "missing key %s after sync", k)
49+
assert.NotNil(t, itB, "missing key %s after sync", k)
4850

4951
if itB.Version < itA.Version {
5052
t.Fatalf("expected B version >= A version for %s", k)

0 commit comments

Comments
 (0)