Skip to content

Commit 2feaaad

Browse files
committed
Update dktest from v0.2.0 to v0.3.0
- Update ReadyFuncs accordingly
1 parent 9870a84 commit 2feaaad

File tree

11 files changed

+42
-23
lines changed

11 files changed

+42
-23
lines changed

Diff for: Gopkg.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@
103103

104104
[[constraint]]
105105
name = "github.com/dhui/dktest"
106-
version = "0.2.2"
106+
version = "0.3.0"

Diff for: database/cassandra/cassandra_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cassandra
22

33
import (
4+
"context"
45
"fmt"
56
"strconv"
67
"testing"
@@ -24,7 +25,7 @@ var (
2425
}
2526
)
2627

27-
func isReady(c dktest.ContainerInfo) bool {
28+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
2829
// Cassandra exposes 5 ports (7000, 7001, 7199, 9042 & 9160)
2930
// We only need the port bound to 9042
3031
ip, portStr, err := c.Port(9042)

Diff for: database/cockroachdb/cockroachdb_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cockroachdb
33
// error codes https://github.com/lib/pq/blob/master/error.go
44

55
import (
6+
"context"
67
"database/sql"
78
"fmt"
89
"strings"
@@ -26,7 +27,7 @@ var (
2627
specs = []dktesting.ContainerSpec{{ImageName: "cockroachdb/cockroach:v1.0.2", Options: opts}}
2728
)
2829

29-
func isReady(c dktest.ContainerInfo) bool {
30+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
3031
ip, port, err := c.Port(defaultPort)
3132
if err != nil {
3233
fmt.Println("port error:", err)
@@ -38,7 +39,7 @@ func isReady(c dktest.ContainerInfo) bool {
3839
fmt.Println("open error:", err)
3940
return false
4041
}
41-
if err := db.Ping(); err != nil {
42+
if err := db.PingContext(ctx); err != nil {
4243
fmt.Println("ping error:", err)
4344
return false
4445
}

Diff for: database/mongodb/mongodb_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ func mongoConnectionString(host, port string) string {
3636
return fmt.Sprintf("mongodb://%s:%s/testMigration?connect=single", host, port)
3737
}
3838

39-
func isReady(c dktest.ContainerInfo) bool {
39+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
4040
ip, port, err := c.FirstPort()
4141
if err != nil {
4242
return false
4343
}
4444

45-
client, err := mongo.Connect(context.TODO(), mongoConnectionString(ip, port))
45+
client, err := mongo.Connect(ctx, mongoConnectionString(ip, port))
4646
if err != nil {
4747
return false
4848
}
49-
defer client.Disconnect(context.TODO())
50-
if err = client.Ping(context.TODO(), nil); err != nil {
49+
defer client.Disconnect(ctx)
50+
if err = client.Ping(ctx, nil); err != nil {
5151
switch err {
5252
case io.EOF:
5353
return false

Diff for: database/mysql/mysql_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package mysql
22

33
import (
4+
"context"
45
"database/sql"
56
sqldriver "database/sql/driver"
67
"fmt"
@@ -33,7 +34,7 @@ var (
3334
}
3435
)
3536

36-
func isReady(c dktest.ContainerInfo) bool {
37+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
3738
ip, port, err := c.Port(defaultPort)
3839
if err != nil {
3940
return false
@@ -44,7 +45,7 @@ func isReady(c dktest.ContainerInfo) bool {
4445
return false
4546
}
4647
defer db.Close()
47-
if err = db.Ping(); err != nil {
48+
if err = db.PingContext(ctx); err != nil {
4849
switch err {
4950
case sqldriver.ErrBadConn, mysql.ErrInvalidConn:
5051
return false

Diff for: database/postgres/postgres_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func pgConnectionString(host, port string) string {
3737
return fmt.Sprintf("postgres://postgres@%s:%s/postgres?sslmode=disable", host, port)
3838
}
3939

40-
func isReady(c dktest.ContainerInfo) bool {
40+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
4141
ip, port, err := c.FirstPort()
4242
if err != nil {
4343
return false
@@ -48,7 +48,7 @@ func isReady(c dktest.ContainerInfo) bool {
4848
return false
4949
}
5050
defer db.Close()
51-
if err = db.Ping(); err != nil {
51+
if err = db.PingContext(ctx); err != nil {
5252
switch err {
5353
case sqldriver.ErrBadConn, io.EOF:
5454
return false

Diff for: database/redshift/redshift_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func connectionString(schema, host, port string) string {
4242
return fmt.Sprintf("%s://postgres@%s:%s/postgres?sslmode=disable", schema, host, port)
4343
}
4444

45-
func isReady(c dktest.ContainerInfo) bool {
45+
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
4646
ip, port, err := c.FirstPort()
4747
if err != nil {
4848
return false
@@ -53,7 +53,7 @@ func isReady(c dktest.ContainerInfo) bool {
5353
return false
5454
}
5555
defer db.Close()
56-
if err = db.Ping(); err != nil {
56+
if err = db.PingContext(ctx); err != nil {
5757
switch err {
5858
case sqldriver.ErrBadConn, io.EOF:
5959
return false

Diff for: dktesting/example_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dktesting_test
22

33
import (
4+
"context"
45
"testing"
56
)
67

@@ -15,9 +16,9 @@ import (
1516
func ExampleParallelTest() {
1617
t := &testing.T{} // Should actually be used in a Test
1718

18-
var isReady = func(c dktest.ContainerInfo) bool {
19+
var isReady = func(ctx context.Context, c dktest.ContainerInfo) bool {
1920
// Return true if the container is ready to run tests.
20-
// Don't block here though.
21+
// Don't block here though. Use the Context to timeout container ready checks.
2122
return true
2223
}
2324

Diff for: go.mod

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ require (
88
github.com/cockroachdb/apd v1.1.0 // indirect
99
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c
1010
github.com/cznic/ql v1.2.0
11-
github.com/dhui/dktest v0.2.2
11+
github.com/dhui/dktest v0.3.0
1212
github.com/docker/docker v0.7.3-0.20190108045446-77df18c24acf
1313
github.com/fsouza/fake-gcs-server v1.3.0
1414
github.com/go-ini/ini v1.39.0 // indirect
1515
github.com/go-sql-driver/mysql v1.4.1
1616
github.com/go-stack/stack v1.8.0 // indirect
1717
github.com/gocql/gocql v0.0.0-20181124151448-70385f88b28b
18+
github.com/golang/mock v1.2.0 // indirect
1819
github.com/google/go-github v17.0.0+incompatible
1920
github.com/google/go-querystring v1.0.0 // indirect
2021
github.com/google/martian v2.1.0+incompatible // indirect
@@ -39,14 +40,16 @@ require (
3940
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
4041
github.com/xdg/stringprep v1.0.0 // indirect
4142
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc // indirect
42-
golang.org/x/net v0.0.0-20190107210223-45ffb0cd1ba0
43+
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
44+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
4345
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
4446
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
4547
golang.org/x/sys v0.0.0-20190108104531-7fbe1cd0fcc2 // indirect
46-
golang.org/x/tools v0.0.0-20190107155254-e063def13b29
48+
golang.org/x/tools v0.0.0-20190108222858-421f03a57a64
4749
google.golang.org/api v0.0.0-20181015145326-625cd1887957
4850
google.golang.org/appengine v1.4.0 // indirect
49-
google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f
51+
google.golang.org/genproto v0.0.0-20190108161440-ae2f86662275
5052
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
5153
gopkg.in/ini.v1 v1.39.0 // indirect
54+
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a // indirect
5255
)

Diff for: go.sum

+12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
4848
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4949
github.com/dhui/dktest v0.2.2 h1:MlsuwzLw0xo2oAryeUxo5BAlTd+xH3iTLBcfIOyCDdg=
5050
github.com/dhui/dktest v0.2.2/go.mod h1:cyzIUfGsBEbZ6BT7tnXqAShHSXCZhSNmFl70sZ7c1yc=
51+
github.com/dhui/dktest v0.3.0 h1:kwX5a7EkLcjo7VpsPQSYJcKGbXBXdjI9FGjuUj1jn6I=
52+
github.com/dhui/dktest v0.3.0/go.mod h1:cyzIUfGsBEbZ6BT7tnXqAShHSXCZhSNmFl70sZ7c1yc=
5153
github.com/docker/distribution v2.7.0+incompatible h1:neUDAlf3wX6Ml4HdqTrbcOHXtfRN0TFIwt6YFL7N9RU=
5254
github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
5355
github.com/docker/docker v0.7.3-0.20190103212154-2b7e084dc98b h1:Y0C03XhDDcak1Ow6em58mBJmUJjxaMfB5sFttITXE0Q=
@@ -78,7 +80,9 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
7880
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
7981
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
8082
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
83+
github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
8184
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
85+
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
8286
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
8387
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
8488
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -176,6 +180,7 @@ golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGq
176180
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
177181
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
178182
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
183+
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
179184
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
180185
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
181186
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -185,6 +190,8 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1
185190
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
186191
golang.org/x/net v0.0.0-20190107210223-45ffb0cd1ba0 h1:1DW40AJQ7AP4nY6ORUGUdkpXyEC9W2GAXcOPaMZK0K8=
187192
golang.org/x/net v0.0.0-20190107210223-45ffb0cd1ba0/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
193+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
194+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
188195
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
189196
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 h1:uESlIz09WIHT2I+pasSXcpLYqYK8wHcdCetU3VuMBJE=
190197
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -208,6 +215,8 @@ golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGm
208215
golang.org/x/tools v0.0.0-20180924175601-e93be7f42f9f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
209216
golang.org/x/tools v0.0.0-20190107155254-e063def13b29 h1:mtLB/BpwjjSIylF0++D6EG1ExPVEIcFKMMwK6HFmbtU=
210217
golang.org/x/tools v0.0.0-20190107155254-e063def13b29/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
218+
golang.org/x/tools v0.0.0-20190108222858-421f03a57a64 h1:9Y3iftuqayHi0EqSzJ3MrPoNIHHcIvicTPdfepyP5tE=
219+
golang.org/x/tools v0.0.0-20190108222858-421f03a57a64/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
211220
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
212221
google.golang.org/api v0.0.0-20180921000521-920bb1beccf7/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
213222
google.golang.org/api v0.0.0-20181015145326-625cd1887957 h1:jwCmWUTrTFfjsobRuGurnCQeW4NZKijaIf6yAXwLR0E=
@@ -222,6 +231,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA
222231
google.golang.org/genproto v0.0.0-20180924164928-221a8d4f7494/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
223232
google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f h1:eT3B0O2ghdSPzjAOznr3oOLyN1HFeYUncYl7FRwg4VI=
224233
google.golang.org/genproto v0.0.0-20181221175505-bd9b4fb69e2f/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
234+
google.golang.org/genproto v0.0.0-20190108161440-ae2f86662275 h1:9oFlwfEGIvmxXTcY53ygNyxIQtWciRHjrnUvZJCYXYU=
235+
google.golang.org/genproto v0.0.0-20190108161440-ae2f86662275/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
225236
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
226237
google.golang.org/grpc v1.15.0 h1:Az/KuahOM4NAidTEuJCv/RonAA7rYsTPkqXVjr+8OOw=
227238
google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
@@ -238,3 +249,4 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
238249
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
239250
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
240251
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
252+
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

0 commit comments

Comments
 (0)