-
Notifications
You must be signed in to change notification settings - Fork 10
/
docker.go
59 lines (48 loc) · 1.74 KB
/
docker.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
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
docker "github.com/fsouza/go-dockerclient"
)
// Docker enumerates interactions with the Docker client, allowing us to use alternate
// implementations for testing.
type Docker interface {
CreateContainer(docker.CreateContainerOptions) (*docker.Container, error)
AttachToContainer(docker.AttachToContainerOptions) error
StartContainer(string, *docker.HostConfig) error
WaitContainer(string) (int, error)
CopyFromContainer(docker.CopyFromContainerOptions) error
RemoveContainer(docker.RemoveContainerOptions) error
KillContainer(docker.KillContainerOptions) error
}
// NullDocker is an embeddable struct that implements the full Docker interface as no-ops, allowing
// you to only implement the calls that you care about for a specific test.
type NullDocker struct{}
// CreateContainer is a no-op that always returns nil and no error.
func (n NullDocker) CreateContainer(docker.CreateContainerOptions) (*docker.Container, error) {
return nil, nil
}
// AttachToContainer is a no-op.
func (n NullDocker) AttachToContainer(docker.AttachToContainerOptions) error {
return nil
}
// StartContainer is a no-op.
func (n NullDocker) StartContainer(string, *docker.HostConfig) error {
return nil
}
// WaitContainer is a no-op.
func (n NullDocker) WaitContainer(string) (int, error) {
return 0, nil
}
// CopyFromContainer is a no-op.
func (n NullDocker) CopyFromContainer(docker.CopyFromContainerOptions) error {
return nil
}
// RemoveContainer is a no-op.
func (n NullDocker) RemoveContainer(docker.RemoveContainerOptions) error {
return nil
}
// KillContainer is a no-op.
func (n NullDocker) KillContainer(docker.KillContainerOptions) error {
return nil
}
// Ensure that NullDocker adheres to the Docker interface.
var _ Docker = NullDocker{}