mocks

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMockContainer

func CreateMockContainer(id string, name string, image string, created time.Time) container.Container

CreateMockContainer creates a container substitute valid for testing

func CreateMockContainerWithConfig added in v1.0.3

func CreateMockContainerWithConfig(id string, name string, image string, created time.Time, config *container2.Config) container.Container

CreateMockContainerWithConfig creates a container substitute valid for testing

func CreateMockContainerWithDigest added in v1.1.0

func CreateMockContainerWithDigest(id string, name string, image string, created time.Time, digest string) container.Container

CreateMockContainerWithDigest should only be used for testing

func CreateMockContainerWithImageInfo added in v1.1.0

func CreateMockContainerWithImageInfo(id string, name string, image string, created time.Time, imageInfo types.ImageInspect) container.Container

CreateMockContainerWithImageInfo should only be used for testing

Types

type MockClient

type MockClient struct {
	TestData *TestData
	// contains filtered or unexported fields
}

MockClient is a mock that passes as a watchtower Client

func CreateMockClient

func CreateMockClient(data *TestData, api cli.CommonAPIClient, pullImages bool, removeVolumes bool) MockClient

CreateMockClient creates a mock watchtower Client for usage in tests

func (MockClient) ExecuteCommand

func (client MockClient) ExecuteCommand(containerID string, command string, timeout int) error

ExecuteCommand is a mock method

func (MockClient) GetContainer

func (client MockClient) GetContainer(containerID string) (container.Container, error)

GetContainer is a mock method

func (MockClient) IsContainerStale

func (client MockClient) IsContainerStale(c container.Container) (bool, error)

IsContainerStale is always true for the mock client

func (MockClient) ListContainers

func (client MockClient) ListContainers(f t.Filter) ([]container.Container, error)

ListContainers is a mock method returning the provided container testdata

func (MockClient) RemoveImageByID

func (client MockClient) RemoveImageByID(id string) error

RemoveImageByID increments the TriedToRemoveImageCount on being called

func (MockClient) RenameContainer

func (client MockClient) RenameContainer(c container.Container, s string) error

RenameContainer is a mock method

func (MockClient) StartContainer

func (client MockClient) StartContainer(c container.Container) (string, error)

StartContainer is a mock method

func (MockClient) StopContainer

func (client MockClient) StopContainer(c container.Container, d time.Duration) error

StopContainer is a mock method

type TestData

type TestData struct {
	TriedToRemoveImageCount int
	NameOfContainerToKeep   string
	Containers              []container.Container
}

TestData is the data used to perform the test

func (*TestData) TriedToRemoveImage

func (testdata *TestData) TriedToRemoveImage() bool

TriedToRemoveImage is a test helper function to check whether RemoveImageByID has been called

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL