forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwait_test.go
47 lines (36 loc) · 1.4 KB
/
wait_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package wait
import (
"context"
"errors"
"io"
"github.com/docker/docker/api/types"
"github.com/docker/go-connections/nat"
tcexec "github.com/testcontainers/testcontainers-go/exec"
)
var ErrPortNotFound = errors.New("port not found")
type MockStrategyTarget struct {
HostImpl func(context.Context) (string, error)
PortsImpl func(context.Context) (nat.PortMap, error)
MappedPortImpl func(context.Context, nat.Port) (nat.Port, error)
LogsImpl func(context.Context) (io.ReadCloser, error)
ExecImpl func(context.Context, []string, ...tcexec.ProcessOption) (int, io.Reader, error)
StateImpl func(context.Context) (*types.ContainerState, error)
}
func (st MockStrategyTarget) Host(ctx context.Context) (string, error) {
return st.HostImpl(ctx)
}
func (st MockStrategyTarget) Ports(ctx context.Context) (nat.PortMap, error) {
return st.PortsImpl(ctx)
}
func (st MockStrategyTarget) MappedPort(ctx context.Context, port nat.Port) (nat.Port, error) {
return st.MappedPortImpl(ctx, port)
}
func (st MockStrategyTarget) Logs(ctx context.Context) (io.ReadCloser, error) {
return st.LogsImpl(ctx)
}
func (st MockStrategyTarget) Exec(ctx context.Context, cmd []string, options ...tcexec.ProcessOption) (int, io.Reader, error) {
return st.ExecImpl(ctx, cmd, options...)
}
func (st MockStrategyTarget) State(ctx context.Context) (*types.ContainerState, error) {
return st.StateImpl(ctx)
}