Skip to content

Commit 0ed38f0

Browse files
Dominik KoteckiDominik Kotecki
authored andcommitted
fix
1 parent 23b7656 commit 0ed38f0

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ require (
1313
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
1414
github.com/Microsoft/go-winio v0.6.0 // indirect
1515
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
16+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
1617
github.com/containerd/containerd v1.6.17 // indirect
1718
github.com/davecgh/go-spew v1.1.1 // indirect
19+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
1820
github.com/docker/distribution v2.8.1+incompatible // indirect
1921
github.com/docker/docker v23.0.1+incompatible // indirect
2022
github.com/docker/go-units v0.5.0 // indirect
@@ -35,6 +37,7 @@ require (
3537
github.com/opencontainers/runc v1.1.4 // indirect
3638
github.com/pkg/errors v0.9.1 // indirect
3739
github.com/pmezard/go-difflib v1.0.0 // indirect
40+
github.com/redis/go-redis/v9 v9.0.2 // indirect
3841
github.com/sirupsen/logrus v1.9.0 // indirect
3942
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
4043
github.com/xdg-go/scram v1.1.2 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2B
66
github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY=
77
github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4=
88
github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
9+
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
10+
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
911
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
1012
github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA=
1113
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
@@ -20,6 +22,8 @@ github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG
2022
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2123
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2224
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
25+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
26+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
2327
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
2428
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
2529
github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY=
@@ -85,6 +89,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8589
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8690
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8791
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
92+
github.com/redis/go-redis/v9 v9.0.2 h1:BA426Zqe/7r56kCcvxYLWe1mkaz71LKF77GwgFzSxfE=
93+
github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
8894
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
8995
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
9096
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=

redis/redis_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package redis
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"testing"
7+
8+
"github.com/redis/go-redis/v9"
9+
)
10+
11+
func TestRedisContainerPing(t *testing.T) {
12+
if testing.Short() {
13+
t.Skip("skipping integration test")
14+
}
15+
config := NewRedisContainerConfigurationBuilder().Build()
16+
// Arrange
17+
ctx := context.Background()
18+
19+
container, err := StartContainer(ctx, config)
20+
if err != nil {
21+
t.Fatal(err)
22+
}
23+
t.Cleanup(func() {
24+
if err := container.Terminate(ctx); err != nil {
25+
t.Fatalf("failed to terminate container: %s", err)
26+
}
27+
})
28+
29+
connectionString, err := container.Url(ctx)
30+
if err != nil {
31+
t.Fatal(fmt.Errorf("can't download redis conectionstring, %w", err))
32+
}
33+
rdb := redis.NewClient(&redis.Options{
34+
Addr: connectionString,
35+
Password: "", // no password set
36+
DB: 0, // use default DB
37+
})
38+
39+
t.Cleanup(func() {
40+
if err := rdb.Close(); err != nil {
41+
t.Fatalf("failed to disconnect redis: %s", err)
42+
}
43+
})
44+
45+
_, err = rdb.Ping(ctx).Result()
46+
if err != nil {
47+
t.Fatal(fmt.Errorf("error when tring ping redis server: %w", err))
48+
}
49+
}

0 commit comments

Comments
 (0)