testutil

package
v0.0.0-...-b8e83fa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUpGitFixtures

func CleanUpGitFixtures(t *testing.T)

CleanUpGitFixtures removes any temp directories created by the go-git test fixtures

func DummyConfig

func DummyConfig() *config.Config

DummyConfig used by tests, to initialize min set of data

func DummyContext

func DummyContext() *config.Context

DummyContext creates a Context config object for unit testing

func DummyContextOptions

func DummyContextOptions() *config.ContextOptions

DummyContextOptions creates ContextOptions config object for unit testing

func DummyManagementConfiguration

func DummyManagementConfiguration() *config.ManagementConfiguration

DummyManagementConfiguration creates a management configuration for unit testing

func DummyManifest

func DummyManifest() *config.Manifest

DummyManifest creates a Manifest config object for unit testing

func DummyManifestOptions

func DummyManifestOptions() *config.ManifestOptions

DummyManifestOptions creates ManifestOptions config object for unit testing

func DummyRepoAuth

func DummyRepoAuth() *config.RepoAuth

DummyRepoAuth creates a RepoAuth config object for unit testing

func DummyRepoCheckout

func DummyRepoCheckout() *config.RepoCheckout

DummyRepoCheckout creates a RepoCheckout config object for unit testing

func DummyRepository

func DummyRepository() *config.Repository

DummyRepository creates a Repository config object for unit testing

func InitConfig

func InitConfig(t *testing.T) (conf *config.Config, cleanup func(*testing.T))

InitConfig creates a Config object meant for testing.

The returned config object will be associated with real files stored in a directory in the user's temporary file storage This directory can be cleaned up by calling the returned "cleanup" function

func NewTestBundle

func NewTestBundle(t *testing.T, fixtureDir string) document.Bundle

NewTestBundle helps to create a new bundle with FakeFs containing documents from fixtureDir

func RunTest

func RunTest(t *testing.T, test *CmdTest)

RunTest either asserts that a specific command's output matches the expected output from its golden file, or generates golden files if the -update flag is passed

func SetupTestFs

func SetupTestFs(t *testing.T, fixtureDir string) fs.FileSystem

SetupTestFs help manufacture a fake file system for testing purposes. It will iterate over the files in fixtureDir, which is a directory relative to the tests themselves, and will write each of those files (preserving names) to an in-memory file system and return that fs

func TempDir

func TempDir(t *testing.T, prefix string) (path string, cleanup func(*testing.T))

TempDir creates a new temporary directory in the system's temporary file storage with a name beginning with prefix. It returns the path of the new directory and a function that can be used to easily clean up that directory

Types

type CmdTest

type CmdTest struct {
	// The name of the test. This will be used when generating golden
	// files
	Name string

	// The values that would be inputted to airshipctl as commands, flags,
	// and arguments. The initial "airshipctl" is implied
	CmdLine string

	// The instantiated version of the root airshipctl command to test
	Cmd *cobra.Command

	// The expected error
	Error error
}

CmdTest is a command to be run on the command line as a test

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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