mocks

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContainerForProgress

func CreateContainerForProgress(index int, idPrefix int, nameFormat string) (wt.Container, wt.ImageID)

CreateContainerForProgress creates a container substitute for tracking session/update progress

func CreateMockContainer

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

CreateMockContainer creates a container substitute valid for testing

func CreateMockContainerWithConfig

func CreateMockContainerWithConfig(id string, name string, image string, running bool, restarting bool, created time.Time, config *dockerContainer.Config) wt.Container

CreateMockContainerWithConfig creates a container substitute valid for testing

func CreateMockContainerWithDigest

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

CreateMockContainerWithDigest should only be used for testing

func CreateMockContainerWithImageInfo

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

CreateMockContainerWithImageInfo should only be used for testing

func CreateMockContainerWithImageInfoP

func CreateMockContainerWithImageInfoP(id string, name string, image string, created time.Time, imageInfo *types.ImageInspect) wt.Container

CreateMockContainerWithImageInfoP should only be used for testing

func CreateMockContainerWithLinks(id string, name string, image string, created time.Time, links []string, imageInfo *types.ImageInspect) wt.Container

CreateMockContainerWithLinks should only be used for testing

func CreateMockImageInfo

func CreateMockImageInfo(image string) *types.ImageInspect

CreateMockImageInfo returns a mock image info struct based on the passed image

func CreateMockProgressReport

func CreateMockProgressReport(states ...session.State) wt.Report

CreateMockProgressReport creates a mock report from a given set of container states All containers will be given a unique ID and name based on its state and index

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, pullImages bool, removeVolumes bool) MockClient

CreateMockClient creates a mock watchtower Client for usage in tests

func (MockClient) ExecuteCommand

func (client MockClient) ExecuteCommand(_ t.ContainerID, command string, _ int) (SkipUpdate bool, err error)

ExecuteCommand is a mock method

func (MockClient) GetContainer

func (client MockClient) GetContainer(_ t.ContainerID) (t.Container, error)

GetContainer is a mock method

func (MockClient) IsContainerStale

func (client MockClient) IsContainerStale(cont t.Container, params t.UpdateParams) (bool, t.ImageID, error)

IsContainerStale is true if not explicitly stated in TestData for the mock client

func (MockClient) ListContainers

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

ListContainers is a mock method returning the provided container testdata

func (MockClient) RemoveImageByID

func (client MockClient) RemoveImageByID(_ t.ImageID) error

RemoveImageByID increments the TriedToRemoveImageCount on being called

func (MockClient) RenameContainer

func (client MockClient) RenameContainer(_ t.Container, _ string) error

RenameContainer is a mock method

func (MockClient) StartContainer

func (client MockClient) StartContainer(_ t.Container) (t.ContainerID, error)

StartContainer is a mock method

func (MockClient) StopContainer

func (client MockClient) StopContainer(c t.Container, _ time.Duration) error

StopContainer is a mock method

func (MockClient) WarnOnHeadPullFailed

func (client MockClient) WarnOnHeadPullFailed(_ t.Container) bool

WarnOnHeadPullFailed is always true for the mock client

type TestData

type TestData struct {
	TriedToRemoveImageCount int
	NameOfContainerToKeep   string
	Containers              []t.Container
	Staleness               map[string]bool
}

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