testcase

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

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

Case contains all the test steps and the Kubernetes client and other global configuration for a test. It represents a leaf directory containing test step files. Case lifecycle:

  1. gets created (directly by Harness.LoadTests()) before the test's dedicated testing.T comes to file. At this point the namespace name is determined. The following steps are in the scope of the testing.T:
  2. has .SetLogger() called to assign a logger
  3. has .LoadTestSteps() called
  4. has .Run() called, which: 4a. calls setup(), which: prepares the clients unless lazy-loaded, and creates their namespaces if needed (and in this case also schedules namespace deletion for test cleanup time) 4b. for each step: sets the step up, prepares its client if lazy-loaded, and runs the step

func NewCase

func NewCase(name string, parentPath string, options ...CaseOption) *Case

NewCase returns a new test case object.

func (*Case) GetName

func (c *Case) GetName() string

GetName returns the name of the test case.

func (*Case) LoadTestSteps

func (c *Case) LoadTestSteps() error

LoadTestSteps loads all the test steps for a test case.

func (*Case) Run

func (c *Case) Run(test *testing.T, rep report.TestReporter)

Run runs a test case including all of its steps.

func (*Case) SetLogger

func (c *Case) SetLogger(logger testutils.Logger)

SetLogger sets the logger for the test case.

type CaseOption

type CaseOption func(*Case)

CaseOption represents a functional option for configuring a Case.

func WithClients

func WithClients(getClientFunc getClientFuncType, getDiscoveryClientFunc getDiscoveryClientFuncType) CaseOption

WithClients sets both the client and discovery client functions.

func WithIgnoreFiles added in v0.24.0

func WithIgnoreFiles(patterns []string) CaseOption

WithIgnoreFiles sets the list of file patterns to ignore.

func WithLogSuppressions

func WithLogSuppressions(suppressions []string) CaseOption

WithLogSuppressions sets the list of log types to suppress.

func WithNamespace

func WithNamespace(ns string) CaseOption

WithNamespace sets the preferred namespace. If empty or not specified, a random namespace name will be generated.

func WithRunLabels

func WithRunLabels(runLabels labels.Set) CaseOption

WithRunLabels sets the run labels.

func WithSkipDelete

func WithSkipDelete(skip bool) CaseOption

WithSkipDelete sets whether to skip deletion of resources.

func WithTemplateVars

func WithTemplateVars(vars map[string]any) CaseOption

func WithTimeout

func WithTimeout(timeout int) CaseOption

WithTimeout sets the timeout in seconds.

type T added in v0.24.0

type T interface {
	Context() context.Context
	Cleanup(f func())
	Error(args ...any)
}

Jump to

Keyboard shortcuts

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