testutil

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockDefaultConfigPath added in v0.2.0

func MockDefaultConfigPath(path string) func()

MockDefaultConfigPath changes the global default config path to a user-defined location and returns a func to restore it.

Usage example in tests:

defer testutil.MockDefaultConfigPath(configPath)()

func MockRepositoryCacheDir added in v0.2.0

func MockRepositoryCacheDir(dir string) func()

MockRepositoryCacheDir changes the global repository cache dir to a temporary directory and returns a func to restore it.

Usage example in tests:

defer testutil.MockRepositoryCacheDir(t.TempDir())()

func Setenv added in v0.2.0

func Setenv(key, value string) func()

Unsetenv set an environment variable and returns a func to restore it to its previous value.

Usage example in tests:

defer testutil.Setenv(t, key, value)()

func Unsetenv added in v0.2.0

func Unsetenv(key string) func()

Unsetenv unset an environment variable and returns a func to restore it to its previous value.

Usage example in tests:

defer testutil.Unsetenv(t, key)()

Types

type ConfigFileBuilder

type ConfigFileBuilder struct {
	*testing.T
	kickoff.Config
}

ConfigFileBuilder is a utility to build kickoff config files in tests.

func NewConfigFileBuilder

func NewConfigFileBuilder(t *testing.T) *ConfigFileBuilder

NewConfigFileBuilder creates a new *ConfigFileBuilder.

func (*ConfigFileBuilder) Create

func (b *ConfigFileBuilder) Create() string

Create creates the config file in a temp dir that gets cleaned up after the current test.

func (*ConfigFileBuilder) WithProjectOwner

func (b *ConfigFileBuilder) WithProjectOwner(owner string) *ConfigFileBuilder

WithProjectOwner sets the project.owner config field.

func (*ConfigFileBuilder) WithRepository

func (b *ConfigFileBuilder) WithRepository(name, url string) *ConfigFileBuilder

WithRepository adds a repository with name and url to the config.

func (*ConfigFileBuilder) WithValues

func (b *ConfigFileBuilder) WithValues(values template.Values) *ConfigFileBuilder

WithValues sets the values in the config.

Jump to

Keyboard shortcuts

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