testhelpers

package
v0.30.0-pre2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertBlobsLen added in v0.29.0

func AssertBlobsLen(t *testing.T, path string, expected int)

func AssertBuildpacksHaveDescriptors added in v0.12.0

func AssertBuildpacksHaveDescriptors(t *testing.T, modules []buildpack.BuildModule, descriptors []dist.BuildpackDescriptor)

func AssertContains

func AssertContains(t *testing.T, actual, expected string)

func AssertContainsAllInOrder added in v0.12.0

func AssertContainsAllInOrder(t *testing.T, actual bytes.Buffer, expected ...string)

func AssertContainsMatch

func AssertContainsMatch(t *testing.T, actual, exp string)

AssertContainsMatch matches on content by regular expression

func AssertEq

func AssertEq(t *testing.T, actual, expected interface{}, opts ...cmp.Option)

Assert deep equality (and provide useful difference as a test failure)

func AssertError

func AssertError(t *testing.T, actual error, expected string)

func AssertFalse

func AssertFalse(t *testing.T, actual interface{})

func AssertFunctionName added in v0.12.0

func AssertFunctionName(t *testing.T, fn interface{}, expected string)

func AssertGitHeadEq added in v0.12.0

func AssertGitHeadEq(t *testing.T, path1, path2 string)

func AssertIncludeAllExpectedPatterns added in v0.10.0

func AssertIncludeAllExpectedPatterns(t *testing.T, receivedArgs []string, expectedPatterns ...[]string)

func AssertMatch

func AssertMatch(t *testing.T, actual string, expected string)

func AssertNil

func AssertNil(t *testing.T, actual interface{})

AssertNil checks for nil value, if not nil it fails the test and stops execution immediately.

func AssertNilE added in v0.19.0

func AssertNilE(t *testing.T, actual interface{})

AssertNilE checks for nil value, if not nil it sets test as failed without stopping execution.

func AssertNotContains

func AssertNotContains(t *testing.T, actual, expected string)

func AssertNotContainsMatch

func AssertNotContainsMatch(t *testing.T, actual, exp string)

func AssertNotEq added in v0.12.0

func AssertNotEq(t *testing.T, actual, expected interface{})

Assert deep equality (and provide useful difference as a test failure)

func AssertNotNil

func AssertNotNil(t *testing.T, actual interface{})

func AssertOnTarEntry

func AssertOnTarEntry(t *testing.T, tarPath, entryPath string, assertFns ...TarEntryAssertion)

func AssertSameInstance

func AssertSameInstance(t *testing.T, actual, expected interface{})

Assert the simplistic pointer (or literal value) equality

func AssertSliceContains

func AssertSliceContains(t *testing.T, slice []string, expected ...string)

func AssertSliceContainsInOrder added in v0.12.0

func AssertSliceContainsInOrder(t *testing.T, slice []string, expected ...string)

func AssertSliceContainsMatch added in v0.10.0

func AssertSliceContainsMatch(t *testing.T, slice []string, expected ...string)

func AssertSliceContainsOnly

func AssertSliceContainsOnly(t *testing.T, slice []string, expected ...string)

func AssertSliceNotContains added in v0.11.0

func AssertSliceNotContains(t *testing.T, slice []string, expected ...string)

func AssertTarFileContents added in v0.12.0

func AssertTarFileContents(t *testing.T, tarfile, path, expected string)

func AssertTarHasFile added in v0.12.0

func AssertTarHasFile(t *testing.T, tarFile, path string)

func AssertTarball added in v0.10.0

func AssertTarball(t *testing.T, path string)

func AssertTrue

func AssertTrue(t *testing.T, actual interface{})

func AssertUnique

func AssertUnique(t *testing.T, items ...interface{})

func CheckImageBuildResult added in v0.23.0

func CheckImageBuildResult(response dockertypes.ImageBuildResponse, err error) error

func CopyFile

func CopyFile(t *testing.T, src, dst string)

func CopyFileE added in v0.14.0

func CopyFileE(src, dst string) error

func CreateImage

func CreateImage(t *testing.T, dockerCli client.CommonAPIClient, repoName, dockerFile string)

func CreateImageFromDir

func CreateImageFromDir(t *testing.T, dockerCli client.CommonAPIClient, repoName string, dir string)

func CreateImageOnRemote

func CreateImageOnRemote(t *testing.T, dockerCli client.CommonAPIClient, registryConfig *TestRegistryConfig, repoName, dockerFile string) string

func CreateRegistryFixture added in v0.12.0

func CreateRegistryFixture(t *testing.T, tmpDir, fixturePath string) string

func CreateTAR

func CreateTAR(t *testing.T, srcDir, tarDir string, mode int64) string

func CreateTGZ

func CreateTGZ(t *testing.T, srcDir, tarDir string, mode int64) string

func Digest

func Digest(t *testing.T, repoName string) string

func DockerHostname added in v0.13.0

func DockerHostname(t *testing.T) string

func DockerRmi

func DockerRmi(dockerCli client.CommonAPIClient, repoNames ...string) error

func Eventually

func Eventually(t *testing.T, test func() bool, every time.Duration, timeout time.Duration)

func HTTPGetE

func HTTPGetE(url string, headers map[string]string) (string, error)

func ImageID

func ImageID(t *testing.T, repoName string) string

func LayerFileName added in v0.29.0

func LayerFileName(bp buildpack.BuildModule) string

func MockWriterAndOutput added in v0.12.0

func MockWriterAndOutput() (*color.Console, func() string)

func PullImageWithAuth

func PullImageWithAuth(dockerCli client.CommonAPIClient, ref, registryAuth string) error

func PushImage

func PushImage(dockerCli client.CommonAPIClient, ref string, registryConfig *TestRegistryConfig) error

func RandString

func RandString(n int) string

func RecursiveCopy

func RecursiveCopy(t *testing.T, src, dst string)

func RecursiveCopyE added in v0.14.0

func RecursiveCopyE(src, dst string) error

func RecursiveCopyNow added in v0.11.0

func RecursiveCopyNow(t *testing.T, src, dst string)

func RegistryHost added in v0.13.0

func RegistryHost(host, port string) string

func RequireDocker

func RequireDocker(t *testing.T)

func Run

func Run(t *testing.T, cmd *exec.Cmd) string

func RunContainer

func RunContainer(ctx context.Context, dockerCli client.CommonAPIClient, id string, stdout io.Writer, stderr io.Writer) error

func RunE

func RunE(cmd *exec.Cmd) (string, error)

func SkipIf

func SkipIf(t *testing.T, expression bool, reason string)

func SkipUnless added in v0.13.0

func SkipUnless(t *testing.T, expression bool, reason string)

func TopLayerDiffID

func TopLayerDiffID(t *testing.T, repoName string) string

Types

type AssertionManager added in v0.13.0

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

func NewAssertionManager added in v0.13.0

func NewAssertionManager(testObject *testing.T) AssertionManager

func (AssertionManager) AssertTrimmedContains added in v0.13.0

func (a AssertionManager) AssertTrimmedContains(actual, expected string)

func (AssertionManager) Contains added in v0.13.0

func (a AssertionManager) Contains(actual, expected string)

func (AssertionManager) ContainsAll added in v0.13.0

func (a AssertionManager) ContainsAll(actual string, expected ...string)

func (AssertionManager) ContainsF added in v0.13.0

func (a AssertionManager) ContainsF(actual, expected string, formatArgs ...interface{})

func (AssertionManager) ContainsJSON added in v0.15.0

func (a AssertionManager) ContainsJSON(actualJSON, expectedJSON string)

func (AssertionManager) ContainsTOML added in v0.15.0

func (a AssertionManager) ContainsTOML(actualTOML, expectedTOML string)

func (AssertionManager) ContainsWithMessage added in v0.13.0

func (a AssertionManager) ContainsWithMessage(actual, expected, messageFormat string)

ContainsWithMessage will fail if expected is not contained within actual, messageFormat will be printed as the failure message, with actual interpolated in the message

func (AssertionManager) ContainsYAML added in v0.15.0

func (a AssertionManager) ContainsYAML(actualYAML, expectedYAML string)

func (AssertionManager) Equal added in v0.13.0

func (a AssertionManager) Equal(actual, expected interface{})

func (AssertionManager) EqualJSON added in v0.16.0

func (a AssertionManager) EqualJSON(actualJSON, expectedJSON string)

func (AssertionManager) EqualTOML added in v0.16.0

func (a AssertionManager) EqualTOML(actualTOML, expectedTOML string)

func (AssertionManager) EqualYAML added in v0.16.0

func (a AssertionManager) EqualYAML(actualYAML, expectedYAML string)

func (AssertionManager) Error added in v0.13.0

func (a AssertionManager) Error(actual error)

Error checks that the provided value is an error (non-nil)

func (AssertionManager) ErrorContains added in v0.14.0

func (a AssertionManager) ErrorContains(actual error, expected string)

func (AssertionManager) ErrorWithMessage added in v0.15.0

func (a AssertionManager) ErrorWithMessage(actual error, message string)

func (AssertionManager) ErrorWithMessageF added in v0.15.0

func (a AssertionManager) ErrorWithMessageF(actual error, format string, args ...interface{})

func (AssertionManager) Fails added in v0.14.0

func (a AssertionManager) Fails(actual interface{})

func (*AssertionManager) FileExists added in v0.16.0

func (a *AssertionManager) FileExists(filePath string)

func (*AssertionManager) FileIsNotEmpty added in v0.16.0

func (a *AssertionManager) FileIsNotEmpty(filePath string)

func (AssertionManager) Matches added in v0.13.0

func (a AssertionManager) Matches(actual string, pattern *regexp.Regexp)

func (AssertionManager) MatchesAll added in v0.13.0

func (a AssertionManager) MatchesAll(actual string, patterns ...*regexp.Regexp)

func (AssertionManager) Nil added in v0.13.0

func (a AssertionManager) Nil(actual interface{})

func (AssertionManager) NilWithMessage added in v0.13.0

func (a AssertionManager) NilWithMessage(actual interface{}, message string)

func (AssertionManager) NoMatches added in v0.13.0

func (a AssertionManager) NoMatches(actual string, pattern *regexp.Regexp)

func (AssertionManager) NotContainWithMessage added in v0.13.0

func (a AssertionManager) NotContainWithMessage(actual, expected, messageFormat string)

NotContainWithMessage will fail if expected is contained within actual, messageFormat will be printed as the failure message, with actual interpolated in the message

func (AssertionManager) NotContains added in v0.14.0

func (a AssertionManager) NotContains(actual, expected string)

func (AssertionManager) NotEqual added in v0.14.0

func (a AssertionManager) NotEqual(actual, expected interface{})

func (AssertionManager) NotNil added in v0.13.0

func (a AssertionManager) NotNil(actual interface{})

func (AssertionManager) Succeeds added in v0.14.0

func (a AssertionManager) Succeeds(actual interface{})

func (AssertionManager) TrimmedEq added in v0.13.0

func (a AssertionManager) TrimmedEq(actual, expected string)

func (AssertionManager) TrueWithMessage added in v0.15.0

func (a AssertionManager) TrueWithMessage(actual bool, message string)

type FakeAddedLayerImage added in v0.29.0

type FakeAddedLayerImage struct {
	*fakes.Image
	// contains filtered or unexported fields
}

func (*FakeAddedLayerImage) AddLayerWithDiffID added in v0.29.0

func (f *FakeAddedLayerImage) AddLayerWithDiffID(path, diffID string) error

func (*FakeAddedLayerImage) AddedLayersOrder added in v0.29.0

func (f *FakeAddedLayerImage) AddedLayersOrder() []string

type TarEntryAssertion

type TarEntryAssertion func(t *testing.T, header *tar.Header, data []byte)

func AssertOnNestedTar added in v0.10.0

func AssertOnNestedTar(nestedEntryPath string, assertions ...TarEntryAssertion) TarEntryAssertion

func ContentContains added in v0.10.0

func ContentContains(expected string) TarEntryAssertion

func ContentEquals

func ContentEquals(expected string) TarEntryAssertion

func DoesNotHaveModTime added in v0.9.0

func DoesNotHaveModTime(expectedTime time.Time) TarEntryAssertion

func HasFileMode

func HasFileMode(expectedMode int64) TarEntryAssertion

func HasModTime

func HasModTime(expectedTime time.Time) TarEntryAssertion

func HasOwnerAndGroup

func HasOwnerAndGroup(expectedUID int, expectedGID int) TarEntryAssertion

func IsDirectory

func IsDirectory() TarEntryAssertion

func IsGzipped added in v0.10.0

func IsGzipped() TarEntryAssertion

func IsJSON added in v0.10.0

func IsJSON() TarEntryAssertion

func SymlinksTo

func SymlinksTo(expectedTarget string) TarEntryAssertion

type TarVerifier added in v0.12.0

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

func NewTarVerifier added in v0.12.0

func NewTarVerifier(t *testing.T, tr *tar.Reader, uid, gid int) *TarVerifier

func (*TarVerifier) NextDirectory added in v0.12.0

func (v *TarVerifier) NextDirectory(name string, mode int64)

func (*TarVerifier) NextFile added in v0.12.0

func (v *TarVerifier) NextFile(name, expectedFileContents string, expectedFileMode int64)
func (v *TarVerifier) NextSymLink(name, link string)

func (*TarVerifier) NoMoreFilesExist added in v0.12.0

func (v *TarVerifier) NoMoreFilesExist()

type TestRegistryConfig

type TestRegistryConfig struct {
	RunRegistryHost string
	RunRegistryPort string
	DockerConfigDir string
	// contains filtered or unexported fields
}

func RunRegistry

func RunRegistry(t *testing.T) *TestRegistryConfig

func (*TestRegistryConfig) AuthConfig

func (rc *TestRegistryConfig) AuthConfig() dockerregistry.AuthConfig

func (*TestRegistryConfig) Login

func (rc *TestRegistryConfig) Login(t *testing.T, username string, password string)

func (*TestRegistryConfig) RegistryAuth

func (rc *TestRegistryConfig) RegistryAuth() string

func (*TestRegistryConfig) RegistryCatalog

func (rc *TestRegistryConfig) RegistryCatalog() (string, error)

func (*TestRegistryConfig) RepoName

func (rc *TestRegistryConfig) RepoName(name string) string

func (*TestRegistryConfig) RmRegistry added in v0.18.0

func (rc *TestRegistryConfig) RmRegistry(t *testing.T)

func (*TestRegistryConfig) StopRegistry

func (rc *TestRegistryConfig) StopRegistry(t *testing.T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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