test

package
v28.3.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package test is a test-only package that can be used by other cli package to write unit test.

It as an internal package and cannot be used outside of github.com/docker/cli package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMultipleValues

func CompareMultipleValues(t *testing.T, value, expected string)

CompareMultipleValues compares comma-separated values, whatever the order is

func EnableContentTrust

func EnableContentTrust(c *FakeCli)

EnableContentTrust on the fake cli

func NewFakeStore

func NewFakeStore() credentials.Store

NewFakeStore creates a new file credentials store.

func NewWriterWithHook

func NewWriterWithHook(actualWriter io.Writer, hook func([]byte)) *writerWithHook

NewWriterWithHook returns a io.Writer that still writes to the actualWriter but also calls the hook function after every write. It is useful to use this function when you need to wait for a writer to complete writing inside a test.

func TerminatePrompt

func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli *FakeCli)

Types

type FakeCli

type FakeCli struct {
	command.DockerCli
	// contains filtered or unexported fields
}

FakeCli emulates the default DockerCli

func NewFakeCli

func NewFakeCli(apiClient client.APIClient, opts ...func(*FakeCli)) *FakeCli

NewFakeCli returns a fake for the command.Cli interface

func (*FakeCli) BuildKitEnabled

func (*FakeCli) BuildKitEnabled() (bool, error)

BuildKitEnabled on the fake cli

func (*FakeCli) Client

func (c *FakeCli) Client() client.APIClient

Client returns a docker API client

func (*FakeCli) ConfigFile

func (c *FakeCli) ConfigFile() *configfile.ConfigFile

ConfigFile returns the cli configfile object (to get client configuration)

func (*FakeCli) ContentTrustEnabled

func (c *FakeCli) ContentTrustEnabled() bool

ContentTrustEnabled on the fake cli

func (*FakeCli) ContextStore

func (c *FakeCli) ContextStore() store.Store

ContextStore returns the cli context store

func (*FakeCli) CurrentContext

func (c *FakeCli) CurrentContext() string

CurrentContext returns the cli context

func (*FakeCli) CurrentVersion

func (*FakeCli) CurrentVersion() string

CurrentVersion returns the API version used by FakeCli.

func (*FakeCli) DockerEndpoint

func (c *FakeCli) DockerEndpoint() docker.Endpoint

DockerEndpoint returns the current DockerEndpoint

func (*FakeCli) Err

func (c *FakeCli) Err() *streams.Out

Err returns the output stream (stderr) the cli should write on

func (*FakeCli) ErrBuffer

func (c *FakeCli) ErrBuffer() *bytes.Buffer

ErrBuffer Buffer returns the stderr buffer

func (*FakeCli) In