...

Package test

import "github.com/docker/cli/internal/test"
Overview
Index
Subdirectories

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 ▾

func CompareMultipleValues(t *testing.T, value, expected string)
func EnableContentTrust(c *FakeCli)
func NewFakeStore() credentials.Store
type FakeCli
    func NewFakeCli(apiClient client.APIClient, opts ...func(*FakeCli)) *FakeCli
    func (c *FakeCli) BuildKitEnabled() (bool, error)
    func (c *FakeCli) Client() client.APIClient
    func (c *FakeCli) ConfigFile() *configfile.ConfigFile
    func (c *FakeCli) ContentTrustEnabled() bool
    func (c *FakeCli) ContextStore() store.Store
    func (c *FakeCli) CurrentContext() string
    func (c *FakeCli) CurrentVersion() string
    func (c *FakeCli) DockerEndpoint() docker.Endpoint
    func (c *FakeCli) Err() io.Writer
    func (c *FakeCli) ErrBuffer() *bytes.Buffer
    func (c *FakeCli) In() *streams.In
    func (c *FakeCli) ManifestStore() manifeststore.Store
    func (c *FakeCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
    func (c *FakeCli) Out() *streams.Out
    func (c *FakeCli) OutBuffer() *bytes.Buffer
    func (c *FakeCli) RegistryClient(bool) registryclient.RegistryClient
    func (c *FakeCli) ResetOutputBuffers()
    func (c *FakeCli) ServerInfo() command.ServerInfo
    func (c *FakeCli) SetConfigFile(configFile *configfile.ConfigFile)
    func (c *FakeCli) SetContextStore(contextStore store.Store)
    func (c *FakeCli) SetCurrentContext(name string)
    func (c *FakeCli) SetDockerEndpoint(ep docker.Endpoint)
    func (c *FakeCli) SetErr(err *bytes.Buffer)
    func (c *FakeCli) SetIn(in *streams.In)
    func (c *FakeCli) SetManifestStore(manifestStore manifeststore.Store)
    func (c *FakeCli) SetNotaryClient(notaryClientFunc NotaryClientFuncType)
    func (c *FakeCli) SetOut(out *streams.Out)
    func (c *FakeCli) SetRegistryClient(registryClient registryclient.RegistryClient)
type FakeStore
    func (c *FakeStore) Erase(serverAddress string) error
    func (c *FakeStore) Get(serverAddress string) (types.AuthConfig, error)
    func (c *FakeStore) GetAll() (map[string]types.AuthConfig, error)
    func (c *FakeStore) SetEraseFunc(eraseFunc func(string) error)
    func (c *FakeStore) SetGetAllFunc(getAllFunc func() (map[string]types.AuthConfig, error))
    func (c *FakeStore) SetGetFunc(getFunc func(string) (types.AuthConfig, error))
    func (c *FakeStore) SetStore(store map[string]types.AuthConfig)
    func (c *FakeStore) SetStoreFunc(storeFunc func(types.AuthConfig) error)
    func (c *FakeStore) Store(authConfig types.AuthConfig) error
type NotaryClientFuncType

Package files

cli.go doc.go store.go strings.go

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.

type FakeCli

FakeCli emulates the default DockerCli

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

func NewFakeCli

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

NewFakeCli returns a fake for the command.Cli interface

func (*FakeCli) BuildKitEnabled

func (c *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 (c *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() io.Writer

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

func (c *FakeCli) In() *streams.In

In returns the input stream the cli will use

func (*FakeCli) ManifestStore

func (c *FakeCli) ManifestStore() manifeststore.Store

ManifestStore returns a fake store used for testing

func (*FakeCli) NotaryClient

func (c *FakeCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)

NotaryClient returns an err for testing unless defined

func (*FakeCli) Out

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

Out returns the output stream (stdout) the cli should write on

func (*FakeCli) OutBuffer

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

OutBuffer returns the stdout buffer

func (*FakeCli) RegistryClient

func (c *FakeCli) RegistryClient(bool) registryclient.RegistryClient

RegistryClient returns a fake client for testing

func (*FakeCli) ResetOutputBuffers

func (c *FakeCli) ResetOutputBuffers()

ResetOutputBuffers resets the .OutBuffer() and.ErrBuffer() back to empty

func (*FakeCli) ServerInfo

func (c *FakeCli) ServerInfo() command.ServerInfo

ServerInfo returns API server information for the server used by this client

func (*FakeCli) SetConfigFile

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

SetConfigFile sets the "fake" config file

func (*FakeCli) SetContextStore

func (c *FakeCli) SetContextStore(contextStore store.Store)

SetContextStore sets the "fake" context store

func (*FakeCli) SetCurrentContext

func (c *FakeCli) SetCurrentContext(name string)

SetCurrentContext sets the "fake" current context

func (*FakeCli) SetDockerEndpoint

func (c *FakeCli) SetDockerEndpoint(ep docker.Endpoint)

SetDockerEndpoint sets the "fake" docker endpoint

func (*FakeCli) SetErr

func (c *FakeCli) SetErr(err *bytes.Buffer)

SetErr sets the stderr stream for the cli to the specified io.Writer

func (*FakeCli) SetIn

func (c *FakeCli) SetIn(in *streams.In)

SetIn sets the input of the cli to the specified ReadCloser

func (*FakeCli) SetManifestStore

func (c *FakeCli) SetManifestStore(manifestStore manifeststore.Store)

SetManifestStore on the fake cli

func (*FakeCli) SetNotaryClient

func (c *FakeCli) SetNotaryClient(notaryClientFunc NotaryClientFuncType)

SetNotaryClient sets the internal getter for retrieving a NotaryClient

func (*FakeCli) SetOut

func (c *FakeCli) SetOut(out *streams.Out)

SetOut sets the stdout stream for the cli to the specified io.Writer

func (*FakeCli) SetRegistryClient

func (c *FakeCli) SetRegistryClient(registryClient registryclient.RegistryClient)

SetRegistryClient on the fake cli

type FakeStore

FakeStore implements a credentials.Store that only acts as an in memory map

type FakeStore struct {
    // contains filtered or unexported fields
}

func (*FakeStore) Erase

func (c *FakeStore) Erase(serverAddress string) error

Erase removes the given credentials from the map store

func (*FakeStore) Get

func (c *FakeStore) Get(serverAddress string) (types.AuthConfig, error)

Get retrieves credentials for a specific server from the map store.

func (*FakeStore) GetAll

func (c *FakeStore) GetAll() (map[string]types.AuthConfig, error)

GetAll returns the key value pairs of ServerAddress => Username

func (*FakeStore) SetEraseFunc

func (c *FakeStore) SetEraseFunc(eraseFunc func(string) error)

SetEraseFunc is used to overrides Erase function

func (*FakeStore) SetGetAllFunc

func (c *FakeStore) SetGetAllFunc(getAllFunc func() (map[string]types.AuthConfig, error))

SetGetAllFunc is used to overrides GetAll function

func (*FakeStore) SetGetFunc

func (c *FakeStore) SetGetFunc(getFunc func(string) (types.AuthConfig, error))

SetGetFunc is used to overrides Get function

func (*FakeStore) SetStore

func (c *FakeStore) SetStore(store map[string]types.AuthConfig)

SetStore is used to overrides Set function

func (*FakeStore) SetStoreFunc

func (c *FakeStore) SetStoreFunc(storeFunc func(types.AuthConfig) error)

SetStoreFunc is used to override Store function

func (*FakeStore) Store

func (c *FakeStore) Store(authConfig types.AuthConfig) error

Store saves the given credentials in the map store.

type NotaryClientFuncType

NotaryClientFuncType defines a function that returns a fake notary client

type NotaryClientFuncType func(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)

Subdirectories

Name Synopsis
..