Skip to content

Commit

Permalink
chore: add more tests (#3592)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Sep 27, 2023
1 parent 0ee7a27 commit 421e661
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/iox/textlinescanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package iox
import (
"strings"
"testing"
"testing/iotest"

"github.com/stretchr/testify/assert"
)
Expand All @@ -22,3 +23,10 @@ func TestScanner(t *testing.T) {
}
assert.EqualValues(t, []string{"1", "2", "3", "4"}, lines)
}

func TestBadScanner(t *testing.T) {
scanner := NewTextLineScanner(iotest.ErrReader(iotest.ErrTimeout))
assert.False(t, scanner.Scan())
_, err := scanner.Line()
assert.ErrorIs(t, err, iotest.ErrTimeout)
}
16 changes: 16 additions & 0 deletions core/stores/redis/redisclustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package redis
import (
"testing"

"github.com/alicebob/miniredis/v2"
red "github.com/go-redis/redis/v8"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -41,3 +43,17 @@ func TestSplitClusterAddrs(t *testing.T) {
})
}
}

func TestGetCluster(t *testing.T) {
r := miniredis.RunT(t)
defer r.Close()
c, err := getCluster(&Redis{
Addr: r.Addr(),
Type: ClusterType,
tls: true,
hooks: []red.Hook{durationHook},
})
if assert.NoError(t, err) {
assert.NotNil(t, c)
}
}

0 comments on commit 421e661

Please sign in to comment.