Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
Signed-off-by: MicroOps-cn <[email protected]>
  • Loading branch information
MicroOps-cn committed Feb 8, 2025
1 parent 708ddca commit 1fa90e1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/testutils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"time"

w "github.com/MicroOps-cn/fuck/wrapper"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/go-sql-driver/mysql"
Expand All @@ -48,10 +48,10 @@ func RunWithOpenLDAPContainer(ctx context.Context, t *testing.T, f func(host, ro
t.Log("start openldap container...")

// pull image
images, err := cli.ImageList(ctx, types.ImageListOptions{Filters: filters.NewArgs(filters.Arg("reference", "osixia/openldap:1.5.0"))})
images, err := cli.ImageList(ctx, image.ListOptions{Filters: filters.NewArgs(filters.Arg("reference", "osixia/openldap:1.5.0"))})
require.NoError(t, err)
if len(images) == 0 {
resp, err := cli.ImagePull(ctx, "osixia/openldap:1.5.0", types.ImagePullOptions{})
resp, err := cli.ImagePull(ctx, "osixia/openldap:1.5.0", image.PullOptions{})
require.NoError(t, err)
defer resp.Close()
fd, isTerminal := term.GetFdInfo(os.Stdout)
Expand All @@ -77,11 +77,11 @@ func RunWithOpenLDAPContainer(ctx context.Context, t *testing.T, f func(host, ro
}, nil, nil, "")
require.NoError(t, err)
//nolint:errcheck
defer cli.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true})
defer cli.ContainerRemove(ctx, c.ID, container.RemoveOptions{Force: true})

err = cli.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
err = cli.ContainerStart(ctx, c.ID, container.StartOptions{})
//nolint:errcheck
defer cli.ContainerStop(ctx, c.ID, w.P[time.Duration](time.Minute))
defer cli.ContainerStop(ctx, c.ID, container.StopOptions{Timeout: w.P[int](60)})
require.NoError(t, err)

inspect, err := cli.ContainerInspect(ctx, c.ID)
Expand Down Expand Up @@ -117,10 +117,10 @@ func RunWithMySQLContainer(ctx context.Context, t *testing.T, f func(host, rootP
t.Log("start mysql container...")

// pull image
images, err := cli.ImageList(ctx, types.ImageListOptions{Filters: filters.NewArgs(filters.Arg("reference", "mysql:5.7"))})
images, err := cli.ImageList(ctx, image.ListOptions{Filters: filters.NewArgs(filters.Arg("reference", "mysql:5.7"))})
require.NoError(t, err)
if len(images) == 0 {
resp, err := cli.ImagePull(ctx, "mysql:5.7", types.ImagePullOptions{})
resp, err := cli.ImagePull(ctx, "mysql:5.7", image.PullOptions{})
require.NoError(t, err)
defer resp.Close()
fd, isTerminal := term.GetFdInfo(os.Stdout)
Expand All @@ -134,11 +134,11 @@ func RunWithMySQLContainer(ctx context.Context, t *testing.T, f func(host, rootP
}, &container.HostConfig{}, nil, nil, "")
require.NoError(t, err)
//nolint:errcheck
defer cli.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true})
defer cli.ContainerRemove(ctx, c.ID, container.RemoveOptions{Force: true})

err = cli.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
err = cli.ContainerStart(ctx, c.ID, container.StartOptions{})
//nolint:errcheck
defer cli.ContainerStop(ctx, c.ID, w.P[time.Duration](time.Minute))
defer cli.ContainerStop(ctx, c.ID, container.StopOptions{Timeout: w.P[int](60)})
require.NoError(t, err)

inspect, err := cli.ContainerInspect(ctx, c.ID)
Expand Down

0 comments on commit 1fa90e1

Please sign in to comment.