test

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeASymlink(target string) types.GomegaMatcher

BeASymlink asserts that a file is a symlink and the link points to a given target.

func CopyFile

func CopyFile(t *testing.T, source string, destination string)

CopyFile copies source to destination. Before writing, it creates all required parent directories for the destination.

func HaveAppendBuildEnvironment

func HaveAppendBuildEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendBuildEnvironment tests that a layer has an append build environment variable with the expected content.

func HaveAppendLaunchEnvironment

func HaveAppendLaunchEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendBuildEnvironment tests that a layer has an append launch environment variable with the expected content.

func HaveAppendPathBuildEnvironment

func HaveAppendPathBuildEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendPathBuildEnvironment tests that a layer has an append path build environment variable with the expected content.

func HaveAppendPathLaunchEnvironment

func HaveAppendPathLaunchEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendPathBuildEnvironment tests that a layer has an append path launch environment variable with the expected content.

func HaveAppendPathSharedEnvironment

func HaveAppendPathSharedEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendPathSharedEnvironment tests that a layer has an append path shared environment variable with the expected content.

func HaveAppendSharedEnvironment

func HaveAppendSharedEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveAppendSharedEnvironment tests that a layer has an append shared environment variable with the expected content.

func HaveApplicationMetadata

func HaveApplicationMetadata(expected layers.Metadata) types.GomegaMatcher

HaveApplicationMetadata tests that an application metadata has expected content.

func HaveContent

func HaveContent(expected string) types.GomegaMatcher

HaveContent tests that a file has expected content.

func HaveLayerMetadata

func HaveLayerMetadata(build bool, cache bool, launch bool) types.GomegaMatcher

HaveLayerMetadata tests that a layer has a specific metadata configuration.

func HaveLayerVersion

func HaveLayerVersion(version string) types.GomegaMatcher

HaveLayerVersion tests that a layer has a specific version.

func HaveOverrideBuildEnvironment

func HaveOverrideBuildEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveOverrideBuildEnvironment tests that a layer has an override build environment variable with the expected content.

func HaveOverrideLaunchEnvironment

func HaveOverrideLaunchEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveOverrideBuildEnvironment tests that a layer has an override launch environment variable with the expected content.

func HaveOverrideSharedEnvironment

func HaveOverrideSharedEnvironment(name string, format string, args ...interface{}) types.GomegaMatcher

HaveOverrideSharedEnvironment tests that a layer has an override shared environment variable with the expected content.

func HavePermissions

func HavePermissions(expected os.FileMode) types.GomegaMatcher

func HavePersistentMetadata

func HavePersistentMetadata(expected interface{}) types.GomegaMatcher

HavePersistentMetadata tests that an persistent metadata has expected content.

func HaveProfile

func HaveProfile(name string, format string, args ...interface{}) types.GomegaMatcher

HaveProfile tests that a layer has a profile.d file with the expected content.

func ReplaceEnv

func ReplaceEnv(t *testing.T, key string, value string) func()

ReplaceEnv replaces an environment variable. Returns a function for use with defer in order to reset the previous value.

defer ReplaceEnv(t, "alpha", "bravo")()

func ScratchDir

func ScratchDir(t *testing.T, prefix string) string

ScratchDir returns a safe scratch directory for tests to modify.

func TouchFile

func TouchFile(t *testing.T, elem ...string)

TouchFile writes a zero-length file during testing.

func WriteFile

func WriteFile(t *testing.T, filename string, format string, args ...interface{})

WriteFile writes a file during testing.

func WriteFileFromReader

func WriteFileFromReader(t *testing.T, filename string, perm os.FileMode, source io.Reader)

WriteFileFromReader writes a file with the given content from a io.Reader. Before writing, it creates all required parent directories for the file.

func WriteFileWithPerm

func WriteFileWithPerm(t *testing.T, filename string, perm os.FileMode, format string, args ...interface{})

WriteFileWithPerm writes a file with specific permissions during testing.

Types

type BuildFactory

type BuildFactory struct {
	// Build is the configured build to use.
	Build build.Build

	// Home is the home directory to use.
	Home string

	// Output is the BuildPlan output at termination.
	Output buildplan.BuildPlan

	// Runner is the used to capture commands executed outside the process.
	Runner *Runner
	// contains filtered or unexported fields
}

BuildFactory is a factory for creating a test Build.

func NewBuildFactory

func NewBuildFactory(t *testing.T) *BuildFactory

NewBuildFactory creates a new instance of BuildFactory.

func (*BuildFactory) AddBuildPlan

func (f *BuildFactory) AddBuildPlan(name string, dependency buildplan.Dependency)

AddBuildPlan adds an entry to a build plan.

func (*BuildFactory) AddDependency

func (f *BuildFactory) AddDependency(id string, fixturePath string)

AddDependency adds a dependency with version 1.0 to the buildpack metadata and copies a fixture into a cached dependency layer.

func (*BuildFactory) AddDependencyWithDependency

func (f *BuildFactory) AddDependencyWithDependency(dependency buildpack.Dependency, fixturePath string)

AddDependencyWithVersion adds a dependency to the buildpack metadata and copies a fixture into a cached dependency layer

func (*BuildFactory) AddDependencyWithVersion

func (f *BuildFactory) AddDependencyWithVersion(id string, version string, fixturePath string)

AddDependencyWithVersion adds a dependency to the buildpack metadata and copies a fixture into a cached dependency layer

func (*BuildFactory) AddService

func (f *BuildFactory) AddService(name string, credentials services.Credentials, tags ...string)

AddService adds an entry to the collection of services.

func (*BuildFactory) SetDefaultVersion

func (f *BuildFactory) SetDefaultVersion(id, version string)

SetDefaultVersion sets a default dependency version in the buildpack metadata

type Command

type Command struct {
	Bin  string
	Dir  string
	Args []string
}

type DetectFactory

type DetectFactory struct {
	// Detect is the configured detect to use.
	Detect detect.Detect

	// Home is the home directory to use.
	Home string

	// Output is the BuildPlan output at termination.
	Output buildplan.BuildPlan

	// Runner is the used to capture commands executed outside the process.
	Runner *Runner
	// contains filtered or unexported fields
}

DetectFactory is a factory for creating a test Detect.

func NewDetectFactory

func NewDetectFactory(t *testing.T) *DetectFactory

NewDetectFactory creates a new instance of DetectFactory.

func (*DetectFactory) AddBuildPlan

func (f *DetectFactory) AddBuildPlan(name string, dependency buildplan.Dependency)

AddBuildPlan adds an entry to a build plan.

func (*DetectFactory) AddService

func (f *DetectFactory) AddService(name string, credentials services.Credentials, tags ...string)

AddService adds an entry to the collection of services.

type Runner

type Runner struct {
	Commands []Command
	Outputs  []string
}

Runner is an implementation of helper.Runner that collects commands and returns output

func (*Runner) Run

func (r *Runner) Run(bin string, dir string, args ...string) error

Run makes Runner satisfy the helper.Runner interface. This implementation collects the input.

func (*Runner) RunWithOutput

func (r *Runner) RunWithOutput(bin string, dir string, args ...string) ([]byte, error)

RunWithOutput makes Runner satisfy the helper.Runner interface. This implementation collects the input and return configured output.

Jump to

Keyboard shortcuts

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