fix: fix tests

This commit is contained in:
Vladimir Mihailenco 2022-06-04 15:15:43 +03:00
parent 91171f5e19
commit 3a722be811
7 changed files with 17 additions and 16 deletions

View File

@ -26,10 +26,9 @@ fmt:
goimports -w -local github.com/go-redis/redis ./ goimports -w -local github.com/go-redis/redis ./
go_mod_tidy: go_mod_tidy:
go get -u && go mod tidy
set -e; for dir in $(PACKAGE_DIRS); do \ set -e; for dir in $(PACKAGE_DIRS); do \
echo "go mod tidy in $${dir}"; \ echo "go mod tidy in $${dir}"; \
(cd "$${dir}" && \ (cd "$${dir}" && \
go get -u && \ go get -u ./... && \
go mod tidy); \ go mod tidy -compat=1.17); \
done done

View File

@ -2,14 +2,16 @@ package redisotel_test
import ( import (
"context" "context"
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"testing" "testing"
"github.com/go-redis/redis/extra/redisotel/v8" semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"github.com/go-redis/redis/v8"
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
sdktrace "go.opentelemetry.io/otel/sdk/trace" sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace"
"github.com/go-redis/redis/extra/redisotel/v8"
"github.com/go-redis/redis/v8"
) )
func TestNew(t *testing.T) { func TestNew(t *testing.T) {

View File

@ -1,3 +1,4 @@
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos // +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
package pool package pool

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos
// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos // +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos
package pool package pool

View File

@ -86,13 +86,14 @@ var _ = Describe("pool", func() {
cn.SetNetConn(&badConn{}) cn.SetNetConn(&badConn{})
client.Pool().Put(ctx, cn) client.Pool().Put(ctx, cn)
err = client.Ping(ctx).Err()
Expect(err).To(MatchError("bad connection"))
val, err := client.Ping(ctx).Result() val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG")) Expect(val).To(Equal("PONG"))
val, err = client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
pool := client.Pool() pool := client.Pool()
Expect(pool.Len()).To(Equal(1)) Expect(pool.Len()).To(Equal(1))
Expect(pool.IdleLen()).To(Equal(1)) Expect(pool.IdleLen()).To(Equal(1))

View File

@ -192,7 +192,7 @@ var _ = Describe("NewFailoverClusterClient", func() {
err = master.Shutdown(ctx).Err() err = master.Shutdown(ctx).Err()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Eventually(func() error { Eventually(func() error {
return sentinelMaster.Ping(ctx).Err() return master.Ping(ctx).Err()
}, "15s", "100ms").Should(HaveOccurred()) }, "15s", "100ms").Should(HaveOccurred())
// Check that client picked up new master. // Check that client picked up new master.
@ -223,7 +223,7 @@ var _ = Describe("SentinelAclAuth", func() {
var client *redis.Client var client *redis.Client
var sentinel *redis.SentinelClient var sentinel *redis.SentinelClient
var sentinels = func() []*redisProcess { sentinels := func() []*redisProcess {
return []*redisProcess{sentinel1, sentinel2, sentinel3} return []*redisProcess{sentinel1, sentinel2, sentinel3}
} }

View File

@ -142,9 +142,6 @@ var _ = Describe("Tx", func() {
return err return err
} }
err = do()
Expect(err).To(MatchError("bad connection"))
err = do() err = do()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })