Documentation ¶
Overview ¶
Package testservices contains fake services used for unit tests.
Index ¶
- func Copy(src, dest string) error
- type GetResponse
- type ReadDirResponse
- type ReadFileResponse
- type StatResponse
- type TempDirResponse
- type TestFileInfo
- type TestGcloud
- func (g *TestGcloud) ConfigGetValue(ctx context.Context, property string) (string, error)
- func (g *TestGcloud) ContainerClustersGetCredentials(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
- func (g *TestGcloud) ContainerClustersGetCredentialsGoClient(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
- type TestGcsService
- type TestImage
- type TestKubectl
- func (k *TestKubectl) Apply(ctx context.Context, filename, namespace string) error
- func (k *TestKubectl) ApplyFromString(ctx context.Context, configString, namespace string) error
- func (k *TestKubectl) Get(ctx context.Context, kind, name, namespace, format string, ignoreNotFound bool) (string, error)
- type TestOS
- func (o *TestOS) MkdirAll(ctx context.Context, dirname string, perm os.FileMode) error
- func (o *TestOS) ReadDir(ctx context.Context, dirname string) ([]os.FileInfo, error)
- func (o *TestOS) ReadFile(ctx context.Context, filename string) ([]byte, error)
- func (o *TestOS) RemoveAll(ctx context.Context, path string) error
- func (o *TestOS) Stat(ctx context.Context, filename string) (os.FileInfo, error)
- func (o *TestOS) TempDir(ctx context.Context, dir, pattern string) (string, error)
- func (o *TestOS) WriteFile(ctx context.Context, filename string, data []byte, perm os.FileMode) error
- type TestRemote
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GetResponse ¶
StatResponse represents a response tuple for a Stat function call.
type ReadDirResponse ¶
ReadDirResponse represents a response tuple for a ReadDir function call.
type ReadFileResponse ¶
ReadDirResponse represents a response tuple for a ReadFile function call.
type StatResponse ¶
StatResponse represents a response tuple for a Stat function call.
type TempDirResponse ¶
TempDirResponse represents a response tuple for a TempDir function call.
type TestFileInfo ¶
type TestFileInfo struct { // Embed this so we only need to add methods used by testable functions os.FileInfo BaseName string IsDirectory bool }
TestFileInfo implements the os.FileInfo interface.
func (*TestFileInfo) IsDir ¶
func (fi *TestFileInfo) IsDir() bool
IsDir returns true if the file is a directory.
func (*TestFileInfo) Name ¶
func (fi *TestFileInfo) Name() string
type TestGcloud ¶
type TestGcloud struct { ContainerClustersGetCredentialsErr error ConfigGetValueResp string ConfigGetValueErr error }
TestGcloud implements the GcloudService interface.
func (*TestGcloud) ConfigGetValue ¶
ConfigGetValue calls `gcloud config get-value <property>` and returns stdout.
func (*TestGcloud) ContainerClustersGetCredentials ¶
func (g *TestGcloud) ContainerClustersGetCredentials(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
ContainerClustersGetCredentials calls `gcloud container clusters get-credentials <clusterName> --zone=<clusterLocation> --project=<clusterProject>`.
func (*TestGcloud) ContainerClustersGetCredentialsGoClient ¶
func (g *TestGcloud) ContainerClustersGetCredentialsGoClient(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
ContainerClustersGetCredentialsGoClient calls `gcloud container clusters get-credentials <clusterName> --zone=<clusterLocation> --project=<clusterProject>`.
type TestGcsService ¶
type TestImage ¶
type TestImage struct { // Embed this so we only need to add methods used by testable functions v1.Image Hash v1.Hash Err error }
TestImage simplements the v1.Image interface.
type TestKubectl ¶
type TestKubectl struct { ApplyResponse map[string][]error ApplyFromStringResponse map[string][]error GetResponse map[string]map[string][]GetResponse }
TestKubectl implements the KubectlService interface.
func (*TestKubectl) Apply ¶
func (k *TestKubectl) Apply(ctx context.Context, filename, namespace string) error
Apply calls `kubectl apply -f <filename> -n <namespace>`.
func (*TestKubectl) ApplyFromString ¶
func (k *TestKubectl) ApplyFromString(ctx context.Context, configString, namespace string) error
ApplyFromString calls `kubectl apply -f - -n <namespace> < ${configString}`.
type TestOS ¶
type TestOS struct { StatResponse map[string]StatResponse ReadDirResponse map[string]ReadDirResponse ReadFileResponse map[string]ReadFileResponse WriteFileResponse map[string]error MkdirAllResponse map[string]error RemoveAllResponse map[string]error TempDirResponse map[string]TempDirResponse }
TestOS implements the OSService interface.
func (*TestOS) MkdirAll ¶
MkdirAll creates a directory dirname, including all parent directories if they do not exist.
func (*TestOS) ReadDir ¶
ReadDir gets file descriptions for all files contained in a directory dirname.