From 3a722be81180e4d2a9cf0a29dc9a1ee1421f5859 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 4 Jun 2022 15:15:43 +0300 Subject: [PATCH] fix: fix tests --- Makefile | 5 ++--- extra/redisotel/redisotel_test.go | 8 +++++--- internal/pool/conn_check.go | 3 ++- internal/pool/conn_check_dummy.go | 3 ++- pool_test.go | 7 ++++--- sentinel_test.go | 4 ++-- tx_test.go | 3 --- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index a4cfe057..8dcddb24 100644 --- a/Makefile +++ b/Makefile @@ -26,10 +26,9 @@ fmt: goimports -w -local github.com/go-redis/redis ./ go_mod_tidy: - go get -u && go mod tidy set -e; for dir in $(PACKAGE_DIRS); do \ echo "go mod tidy in $${dir}"; \ (cd "$${dir}" && \ - go get -u && \ - go mod tidy); \ + go get -u ./... && \ + go mod tidy -compat=1.17); \ done diff --git a/extra/redisotel/redisotel_test.go b/extra/redisotel/redisotel_test.go index 68aacc4a..883dcf17 100644 --- a/extra/redisotel/redisotel_test.go +++ b/extra/redisotel/redisotel_test.go @@ -2,14 +2,16 @@ package redisotel_test import ( "context" - semconv "go.opentelemetry.io/otel/semconv/v1.7.0" "testing" - "github.com/go-redis/redis/extra/redisotel/v8" - "github.com/go-redis/redis/v8" + semconv "go.opentelemetry.io/otel/semconv/v1.7.0" + "go.opentelemetry.io/otel" sdktrace "go.opentelemetry.io/otel/sdk/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) { diff --git a/internal/pool/conn_check.go b/internal/pool/conn_check.go index 1afdd6fe..74680e4b 100644 --- a/internal/pool/conn_check.go +++ b/internal/pool/conn_check.go @@ -1,3 +1,4 @@ +//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos // +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos package pool @@ -46,4 +47,4 @@ func connCheck(conn net.Conn) error { } return sysErr -} \ No newline at end of file +} diff --git a/internal/pool/conn_check_dummy.go b/internal/pool/conn_check_dummy.go index e7d62808..9408446b 100644 --- a/internal/pool/conn_check_dummy.go +++ b/internal/pool/conn_check_dummy.go @@ -1,3 +1,4 @@ +//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos // +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos package pool @@ -6,4 +7,4 @@ import "net" func connCheck(conn net.Conn) error { return nil -} \ No newline at end of file +} diff --git a/pool_test.go b/pool_test.go index e297b010..7be2ced7 100644 --- a/pool_test.go +++ b/pool_test.go @@ -86,13 +86,14 @@ var _ = Describe("pool", func() { cn.SetNetConn(&badConn{}) client.Pool().Put(ctx, cn) - err = client.Ping(ctx).Err() - Expect(err).To(MatchError("bad connection")) - val, err := client.Ping(ctx).Result() Expect(err).NotTo(HaveOccurred()) Expect(val).To(Equal("PONG")) + val, err = client.Ping(ctx).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(val).To(Equal("PONG")) + pool := client.Pool() Expect(pool.Len()).To(Equal(1)) Expect(pool.IdleLen()).To(Equal(1)) diff --git a/sentinel_test.go b/sentinel_test.go index cc56cbab..d0fa9c95 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -192,7 +192,7 @@ var _ = Describe("NewFailoverClusterClient", func() { err = master.Shutdown(ctx).Err() Expect(err).NotTo(HaveOccurred()) Eventually(func() error { - return sentinelMaster.Ping(ctx).Err() + return master.Ping(ctx).Err() }, "15s", "100ms").Should(HaveOccurred()) // Check that client picked up new master. @@ -223,7 +223,7 @@ var _ = Describe("SentinelAclAuth", func() { var client *redis.Client var sentinel *redis.SentinelClient - var sentinels = func() []*redisProcess { + sentinels := func() []*redisProcess { return []*redisProcess{sentinel1, sentinel2, sentinel3} } diff --git a/tx_test.go b/tx_test.go index 7deb2dfd..030a56cc 100644 --- a/tx_test.go +++ b/tx_test.go @@ -142,9 +142,6 @@ var _ = Describe("Tx", func() { return err } - err = do() - Expect(err).To(MatchError("bad connection")) - err = do() Expect(err).NotTo(HaveOccurred()) })