Skip to content

Commit 48f16d8

Browse files
author
Oleg Laktyushkin
committed
added test to cmdble Do method
1 parent db2321c commit 48f16d8

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

do.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package redis
2+
3+
import "context"
4+
5+
func (c cmdable) Do(ctx context.Context, args ...interface{}) *Cmd {
6+
cmd := NewCmd(ctx, args)
7+
_ = c(ctx, cmd)
8+
return cmd
9+
}

do_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package redis_test
2+
3+
import (
4+
. "github.com/bsm/ginkgo/v2"
5+
. "github.com/bsm/gomega"
6+
7+
"github.com/redis/go-redis/v9"
8+
)
9+
10+
var _ = Describe("Do cmdble", func() {
11+
var client *redis.Client
12+
13+
BeforeEach(func() {
14+
client = redis.NewClient(redisOptions())
15+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
16+
})
17+
18+
AfterEach(func() {
19+
client.Close()
20+
})
21+
22+
It("should pong with Do cmd", func() {
23+
result := client.Conn().Do(ctx, "PING")
24+
Expect(result.Result()).To(Equal("PONG"))
25+
Expect(result.Err()).NotTo(HaveOccurred())
26+
})
27+
})

universal.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ type UniversalClient interface {
228228
PoolStats() *PoolStats
229229
}
230230

231-
func (c cmdable) Do(ctx context.Context, args ...interface{}) *Cmd {
232-
cmd := NewCmd(ctx, args)
233-
_ = c(ctx, cmd)
234-
return cmd
235-
}
236-
237231
var (
238232
_ UniversalClient = (*Client)(nil)
239233
_ UniversalClient = (*ClusterClient)(nil)

0 commit comments

Comments
 (0)