2013-11-09 15:12:23 -05:00
|
|
|
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 15:12:23 -05:00
|
|
|
|
2013-11-09 16:03:01 -05:00
|
|
|
PullCalled bool
|
|
|
|
PullImage string
|
|
|
|
StartCalled bool
|
|
|
|
StartConfig *ContainerConfig
|
|
|
|
StopCalled bool
|
|
|
|
StopID string
|
2013-11-09 15:12:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|