mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 22:20:12 +01:00
Allow user-configurable DOCKER_HOST
This commit is contained in:
parent
00f2875abf
commit
4ba21639a0
10 changed files with 202 additions and 35 deletions
37
container/mockclient/mock.go
Normal file
37
container/mockclient/mock.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package mockclient
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/CenturyLinkLabs/watchtower/container"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
type MockClient struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *MockClient) ListContainers(cf container.ContainerFilter) ([]container.Container, error) {
|
||||
args := m.Called(cf)
|
||||
return args.Get(0).([]container.Container), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockClient) RefreshImage(c *container.Container) error {
|
||||
args := m.Called(c)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *MockClient) Stop(c container.Container, timeout time.Duration) error {
|
||||
args := m.Called(c, timeout)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *MockClient) Start(c container.Container) error {
|
||||
args := m.Called(c)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *MockClient) Rename(c container.Container, name string) error {
|
||||
args := m.Called(c, name)
|
||||
return args.Error(0)
|
||||
}
|
||||
17
container/mockclient/mock_test.go
Normal file
17
container/mockclient/mock_test.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package mockclient
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/CenturyLinkLabs/watchtower/container"
|
||||
)
|
||||
|
||||
func TestMockInterface(t *testing.T) {
|
||||
iface := reflect.TypeOf((*container.Client)(nil)).Elem()
|
||||
mock := &MockClient{}
|
||||
|
||||
if !reflect.TypeOf(mock).Implements(iface) {
|
||||
t.Fatalf("Mock does not implement the Client interface")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue