e2e

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPorchServerRunningInCluster

func IsPorchServerRunningInCluster(t *testing.T) bool

func KubectlCreateNamespace

func KubectlCreateNamespace(t *testing.T, name string)

func KubectlDeleteNamespace

func KubectlDeleteNamespace(t *testing.T, name string)

func KubectlWaitForLoadBalancerIp

func KubectlWaitForLoadBalancerIp(t *testing.T, namespace, name string) string

func KubectlWaitForRepoReady added in v1.4.0

func KubectlWaitForRepoReady(t *testing.T, repoName, namespace string)

func RemovePackagerevFinalizers

func RemovePackagerevFinalizers(t *testing.T, namespace string)

func WriteTestCaseConfig

func WriteTestCaseConfig(t *testing.T, tc *TestCaseConfig)

Types

type CliTestSuite added in v1.3.1

type CliTestSuite struct {
	// The path of the directory containing the test cases.
	TestDataPath string
	// SearchAndReplace contains (search, replace) pairs that will be applied to the command output before comparison.
	SearchAndReplace map[string]string
	// GitServerURL is the URL of the git server to use for the tests.
	GitServerURL string
	// PorchctlCommand is the full path to the porchctl command to be tested.
	PorchctlCommand string
}

func NewCliTestSuite added in v1.3.1

func NewCliTestSuite(t *testing.T, testdataDir string) *CliTestSuite

NewCliTestSuite creates a new CliTestSuite based on the configuration in the testdata directory.

func (*CliTestSuite) Porchctl added in v1.3.1

func (s *CliTestSuite) Porchctl(t *testing.T, args ...string) error

Porchctl runs the porchctl command under test with the given arguments.

func (*CliTestSuite) RegisterRepository added in v1.3.1

func (s *CliTestSuite) RegisterRepository(t *testing.T, repoURL, namespace, name string)

func (*CliTestSuite) RunTestCase added in v1.3.1

func (s *CliTestSuite) RunTestCase(t *testing.T, tc TestCaseConfig)

RunTestCase runs a single test case.

func (*CliTestSuite) RunTests added in v1.3.1

func (s *CliTestSuite) RunTests(t *testing.T)

RunTests runs the test cases in the testdata directory.

func (*CliTestSuite) ScanTestCases added in v1.3.1

func (s *CliTestSuite) ScanTestCases(t *testing.T) []TestCaseConfig

ScanTestCases parses the test case configs from the testdata directory.

type Command

type Command struct {
	// Args is a list of args for the kpt CLI.
	Args []string `yaml:"args,omitempty"`
	// StdIn contents will be passed as the command's standard input, if not empty.
	Stdin string `yaml:"stdin,omitempty"`
	// StdOut is the standard output expected from the command.
	Stdout string `yaml:"stdout,omitempty"`
	// StdErr is the standard error output expected from the command.
	Stderr string `yaml:"stderr,omitempty"`
	// ExitCode is the expected exit code frm the command.
	ExitCode int `yaml:"exitCode,omitempty"`
	// Yaml indicates that stdout is yaml and the test will reformat it for stable ordering
	Yaml bool `yaml:"yaml,omitempty"`
	// IgnoreWhitespace indicates that whitespace differences should be ignored in the output
	IgnoreWhitespace bool `yaml:"ignoreWhitespace,omitempty"`
	// StdErrTabToWhitespace replaces "\t" (tab) character with whitespace "  "
	StdErrTabToWhitespace bool `yaml:"stdErrTabToWhitespace,omitempty"`
	// ContainsErrorString changes Stderr check from exact string match to contains string match
	ContainsErrorString bool `yaml:"containsErrorString,omitempty"`
}

type TestCaseConfig

type TestCaseConfig struct {
	// TestCase is the name of the test case.
	TestCase string `yaml:"-"`
	// ConfigFile stores the name of the config file from which the config was loaded.
	// Used when generating or updating golden files.
	ConfigFile string `yaml:"-"`
	// Repository is the name of the k8s Repository resource to register the default Git repo.
	Repository string `yaml:"repository,omitempty"`
	// Commands is a list of porchctl commands to be executed by the test.
	Commands []Command `yaml:"commands,omitempty"`
	// Skip the test? If the value is not empty, it will be used as a message with which to skip the test.
	Skip string `yaml:"skip,omitempty"`
}

func ReadTestCaseConfig

func ReadTestCaseConfig(t *testing.T, name, path string) TestCaseConfig

Jump to

Keyboard shortcuts

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