Update go deps to v4 (#4482)
* Update go deps to v4 Generated by renovateBot * update dockertest to v4 * fix --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: David Zhao <dz@livekit.io>
This commit is contained in:
co-authored by
David Zhao
parent
20fd1ad2c1
commit
dc8e0310ad
+15
-10
@@ -15,27 +15,31 @@
|
||||
package service_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/ory/dockertest/v3"
|
||||
mobyclient "github.com/moby/moby/client"
|
||||
"github.com/ory/dockertest/v4"
|
||||
)
|
||||
|
||||
var Docker *dockertest.Pool
|
||||
var Docker dockertest.ClosablePool
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
pool, err := dockertest.NewPool("")
|
||||
ctx := context.Background()
|
||||
pool, err := dockertest.NewPool(ctx, "")
|
||||
if err != nil {
|
||||
log.Fatalf("Could not construct pool: %s", err)
|
||||
}
|
||||
|
||||
// uses pool to try to connect to Docker
|
||||
err = pool.Client.Ping()
|
||||
_, err = pool.Client().Ping(ctx, mobyclient.PingOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("Could not connect to Docker: %s", err)
|
||||
}
|
||||
@@ -46,7 +50,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func waitTCPPort(t testing.TB, addr string) {
|
||||
if err := Docker.Retry(func() error {
|
||||
if err := Docker.Retry(t.Context(), 30*time.Second, func() error {
|
||||
conn, err := net.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
@@ -62,15 +66,16 @@ func waitTCPPort(t testing.TB, addr string) {
|
||||
var redisLast atomic.Uint32
|
||||
|
||||
func runRedis(t testing.TB) string {
|
||||
c, err := Docker.RunWithOptions(&dockertest.RunOptions{
|
||||
Name: fmt.Sprintf("lktest-redis-%d", redisLast.Inc()),
|
||||
Repository: "redis", Tag: "latest",
|
||||
})
|
||||
c, err := Docker.Run(t.Context(),
|
||||
"redis",
|
||||
dockertest.WithName(fmt.Sprintf("lktest-redis-%d", redisLast.Inc())),
|
||||
dockertest.WithTag("latest"),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_ = Docker.Purge(c)
|
||||
_ = c.Close(t.Context())
|
||||
})
|
||||
addr := c.GetHostPort("6379/tcp")
|
||||
waitTCPPort(t, addr)
|
||||
|
||||
Reference in New Issue
Block a user