packer-cn/builder/docker/driver_mock.go

35 lines
696 B
Go
Raw Normal View History

package docker
// MockDriver is a driver implementation that can be used for tests.
type MockDriver struct {
2013-11-09 16:03:01 -05:00
PullError error
StartID string
StartError error
StopError error
2013-11-09 16:03:01 -05:00
PullCalled bool
PullImage string
StartCalled bool
StartConfig *ContainerConfig
StopCalled bool
StopID string
}
func (d *MockDriver) Pull(image string) error {
d.PullCalled = true
d.PullImage = image
return d.PullError
}
2013-11-09 16:03:01 -05:00
func (d *MockDriver) StartContainer(config *ContainerConfig) (string, error) {
d.StartCalled = true
d.StartConfig = config
return d.StartID, d.StartError
}
func (d *MockDriver) StopContainer(id string) error {
d.StopCalled = true
d.StopID = id
return d.StopError
}