framework

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CapabilitiesSpec

type CapabilitiesSpec struct {
	// KubeVersion represents the kubernetes version which is discoverable via `.Capabilities.KubeVersion`.
	KubeVersion *KubeVersion `json:"kubeVersion,omitempty" yaml:"kubeVersion,omitempty"`
}

CapabilitiesSpec represents the `Capabilities` in Helm.

type KubeVersion

type KubeVersion struct {
	Version string `json:"version,omitempty" yaml:"version,omitempty"` // i.e. v1.18
	Major   string `json:"major,omitempty" yaml:"major,omitempty"`     // i.e. 1
	Minor   string `json:"minor,omitempty" yaml:"minor,omitempty"`     // i.e. 18
}

KubeVersion is the Kubernetes version.

type Loader

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

Loader loads a test suite.

func NewLoader

func NewLoader(rootDir string, opts ...LoaderOpt) *Loader

NewLoader returns a loader and applies options to it.

func (*Loader) LoadSuite

func (loader *Loader) LoadSuite() (*Test, error)

LoadSuite loads a helmtest suite from the given directory.

type LoaderOpt

type LoaderOpt func(loader *Loader)

LoaderOpt allows setting custom options.

func WithAdditionalTestDirs

func WithAdditionalTestDirs(path ...string) LoaderOpt

WithAdditionalTestDirs adds additional test source directories which are scanned for tests.

type RawDict

type RawDict map[string]interface{}

RawDict is an alias for map[string]interface{}, that is needed because `yaml.Unmarshal` and `json.Unmarshal` differ in that the latter will never produce int values, while the former may.

func (*RawDict) UnmarshalYAML

func (d *RawDict) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML unmarshals a RawDict from YAML, making sure that the resulting type matches the result of json.Unmarshal on the equivalent JSON.

type ReleaseSpec

type ReleaseSpec struct {
	Name      string `json:"name,omitempty" yaml:"name,omitempty"`
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Revision  *int   `json:"revision,omitempty" yaml:"revision,omitempty"`
	IsInstall *bool  `json:"isInstall,omitempty" yaml:"isInstall,omitempty"`
	IsUpgrade *bool  `json:"isUpgrade,omitempty" yaml:"isUpgrade,omitempty"`
}

ReleaseSpec specifies how the release options for Helm will be constructed.

type ServerSpec

type ServerSpec struct {
	// AvailableSchemas are the names of schemas that are available on the server (i.e., that rendered objects must
	// pass validation against, but not necessarily discoverable via `.Capabilities.APIVersions`).
	AvailableSchemas []string `json:"availableSchemas,omitempty" yaml:"availableSchemas,omitempty"`
	// VisibleSchemas are the names of schemas that are available on the server AND discoverable via
	// `.Capabilities.APIVersions`.
	VisibleSchemas []string `json:"visibleSchemas,omitempty" yaml:"visibleSchemas,omitempty"`
	// Objects are definitions of objects visible to Helm's k8s client, for example via the `lookup` function.
	Objects []map[string]interface{} `json:"objects,omitempty" yaml:"objects,omitempty"`

	// NoInherit indicates that server-side settings should *not* be inherited from the enclosing scope.
	NoInherit bool `json:"noInherit,omitempty" yaml:"noInherit,omitempty"`
}

ServerSpec specifies how the model of the server will be constructed.

type Target

type Target struct {
	Chart          *chart.Chart
	ReleaseOptions chartutil.ReleaseOptions
	Capabilities   *chartutil.Capabilities

	SchemaRegistry schemas.Registry
}

Target is the target to run a test against. This must at the minimum include a chart and default release options (such as the release name or the namespace). Capabilities is optional and will default to the standard capabilities used by Helm in client-only mode.

type Test

type Test struct {
	Name string `json:"name,omitempty" yaml:"name,omitempty"`

	Values RawDict `json:"values,omitempty" yaml:"values,omitempty"`
	Set    RawDict `json:"set,omitempty" yaml:"set,omitempty"`

	Defs         string            `json:"defs,omitempty" yaml:"defs,omitempty"`
	Release      *ReleaseSpec      `json:"release,omitempty" yaml:"release,omitempty"`
	Server       *ServerSpec       `json:"server,omitempty" yaml:"server,omitempty"`
	Capabilities *CapabilitiesSpec `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`

	Expect      string `json:"expect,omitempty" yaml:"expect,omitempty"`
	ExpectError *bool  `json:"expectError,omitempty" yaml:"expectError,omitempty"`

	Tests []*Test `json:"tests,omitempty" yaml:"tests,omitempty"`
	// contains filtered or unexported fields
}

Test defines a helmtest test. A Test can be regarded as the equivalent of the *testing.T scope of a Go unit test. Tests are scoped, and a test may either define concrete expectations, or contain an arbitrary number of nested tests. See README.md in this directory for a more detailed explanation.

func (*Test) DoRun

func (t *Test) DoRun(testingT *testing.T, tgt *Target)

DoRun runs a test directly, without an intermediate `testingT.Run` invocation.

func (*Test) Run

func (t *Test) Run(testingT *testing.T, tgt *Target)

Run runs a test against the given target.

func (*Test) UnmarshalYAML

func (t *Test) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML unmarshals a test spec from YAML, preserving line information that we're interested in.

Jump to

Keyboard shortcuts

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