Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jun 4, 2022
1 parent 91171f5 commit 3a722be
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions extra/redisotel/redisotel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion internal/pool/conn_check.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,4 +47,4 @@ func connCheck(conn net.Conn) error {
}

return sysErr
}
}
3 changes: 2 additions & 1 deletion internal/pool/conn_check_dummy.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -6,4 +7,4 @@ import "net"

func connCheck(conn net.Conn) error {
return nil
}
}
7 changes: 4 additions & 3 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}
}

Expand Down
3 changes: 0 additions & 3 deletions tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ var _ = Describe("Tx", func() {
return err
}

err = do()
Expect(err).To(MatchError("bad connection"))

err = do()
Expect(err).NotTo(HaveOccurred())
})
Expand Down

0 comments on commit 3a722be

Please sign in to comment.