...

Package kusttest_test

import "sigs.k8s.io/kustomize/api/testutils/kusttest"
Overview
Index

Overview ▾

Index ▾

func AssertActualEqualsExpectedWithTweak(t *testing.T, m resmap.ResMap, tweaker func([]byte) []byte, expected string)
func CreateKustDir(t *testing.T, content string) (filesys.FileSystem, filesys.ConfirmedDir)
func Setup(t *testing.T) (filesys.FileSystem, filesys.ConfirmedDir)
type AssertFunc
type Harness
    func MakeHarness(t *testing.T) Harness
    func MakeHarnessWithFs(t *testing.T, fSys filesys.FileSystem) Harness
    func (th Harness) AssertActualEqualsExpected(m resmap.ResMap, expected string)
    func (th Harness) AssertActualEqualsExpectedNoIdAnnotations(m resmap.ResMap, expected string)
    func (th Harness) AssertActualEqualsExpectedWithTweak(m resmap.ResMap, tweaker func([]byte) []byte, expected string)
    func (th Harness) GetFSys() filesys.FileSystem
    func (th Harness) GetT() *testing.T
    func (th Harness) MakeDefaultOptions() krusty.Options
    func (th Harness) MakeOptionsPluginsDisabled() krusty.Options
    func (th Harness) MakeOptionsPluginsEnabled() krusty.Options
    func (th Harness) Run(path string, o krusty.Options) resmap.ResMap
    func (th Harness) RunWithErr(path string, o krusty.Options) error
    func (th Harness) WriteC(path string, content string)
    func (th Harness) WriteF(path string, content string)
    func (th Harness) WriteK(path string, content string)
    func (th Harness) WriteLegacyConfigs(fName string)
type HarnessEnhanced
    func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced
    func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced
    func (th *HarnessEnhanced) BuildGoPlugin(g, v, k string) *HarnessEnhanced
    func (th *HarnessEnhanced) ErrIfNoHelm() error
    func (th *HarnessEnhanced) ErrorFromLoadAndRunTransformer(config, input string) error
    func (th *HarnessEnhanced) GetPluginConfig() *types.PluginConfig
    func (th *HarnessEnhanced) GetRoot() string
    func (th *HarnessEnhanced) LoadAndRunGenerator(config string) resmap.ResMap
    func (th *HarnessEnhanced) LoadAndRunGeneratorWithBuildAnnotations(config string) resmap.ResMap
    func (th *HarnessEnhanced) LoadAndRunTransformer(config, input string) resmap.ResMap
    func (th *HarnessEnhanced) MkDir(path string) string
    func (th *HarnessEnhanced) PrepBuiltin(k string) *HarnessEnhanced
    func (th *HarnessEnhanced) PrepExecPlugin(g, v, k string) *HarnessEnhanced
    func (th *HarnessEnhanced) Reset()
    func (th *HarnessEnhanced) ResetLoaderRoot(root string)
    func (th *HarnessEnhanced) RunTransformer(config, input string) (resmap.ResMap, error)
    func (th *HarnessEnhanced) RunTransformerAndCheckError(config, input string, assertFn AssertFunc)
    func (th *HarnessEnhanced) RunTransformerAndCheckResult(config, input, expected string)
    func (th *HarnessEnhanced) RunTransformerFromResMap(config string, resMap resmap.ResMap) (resmap.ResMap, error)

Package files

harness.go harnessenhanced.go hasgett.go ondisk.go plugintestenv.go

func AssertActualEqualsExpectedWithTweak

func AssertActualEqualsExpectedWithTweak(
    t *testing.T,
    m resmap.ResMap,
    tweaker func([]byte) []byte, expected string)

func CreateKustDir

func CreateKustDir(t *testing.T, content string) (filesys.FileSystem, filesys.ConfirmedDir)

CreateKustDir creates a file system on disk and a new directory that holds a kustomization file with content. The directory is removed on test completion.

func Setup

func Setup(t *testing.T) (filesys.FileSystem, filesys.ConfirmedDir)

Setup sets up a file system on disk and directory that is cleaned after test completion.

type AssertFunc

type AssertFunc func(t *testing.T, err error)

type Harness

Harness manages a test environment.

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

func MakeHarness

func MakeHarness(t *testing.T) Harness

func MakeHarnessWithFs

func MakeHarnessWithFs(
    t *testing.T, fSys filesys.FileSystem) Harness

func (Harness) AssertActualEqualsExpected

func (th Harness) AssertActualEqualsExpected(
    m resmap.ResMap, expected string)

func (Harness) AssertActualEqualsExpectedNoIdAnnotations

func (th Harness) AssertActualEqualsExpectedNoIdAnnotations(m resmap.ResMap, expected string)

func (Harness) AssertActualEqualsExpectedWithTweak

func (th Harness) AssertActualEqualsExpectedWithTweak(
    m resmap.ResMap, tweaker func([]byte) []byte, expected string)

func (Harness) GetFSys

func (th Harness) GetFSys() filesys.FileSystem

func (Harness) GetT

func (th Harness) GetT() *testing.T

func (Harness) MakeDefaultOptions

func (th Harness) MakeDefaultOptions() krusty.Options

func (Harness) MakeOptionsPluginsDisabled

func (th Harness) MakeOptionsPluginsDisabled() krusty.Options

This has no impact on Builtin plugins, as they are always enabled.

func (Harness) MakeOptionsPluginsEnabled

func (th Harness) MakeOptionsPluginsEnabled() krusty.Options

Enables use of non-builtin plugins.

func (Harness) Run

func (th Harness) Run(path string, o krusty.Options) resmap.ResMap

Run, failing on error.

func (Harness) RunWithErr

func (th Harness) RunWithErr(path string, o krusty.Options) error

Run, failing if there is no error.

func (Harness) WriteC

func (th Harness) WriteC(path string, content string)

func (Harness) WriteF

func (th Harness) WriteF(path string, content string)

func (Harness) WriteK

func (th Harness) WriteK(path string, content string)

func (Harness) WriteLegacyConfigs

func (th Harness) WriteLegacyConfigs(fName string)

type HarnessEnhanced

HarnessEnhanced manages a full plugin environment for tests.

type HarnessEnhanced struct {
    // An instance of *testing.T, and a filesystem (likely in-memory)
    // for loading test data - plugin config, resources to transform, etc.
    Harness
    // contains filtered or unexported fields
}

func MakeEnhancedHarness

func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced

func MakeEnhancedHarnessWithTmpRoot

func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced

func (*HarnessEnhanced) BuildGoPlugin

func (th *HarnessEnhanced) BuildGoPlugin(g, v, k string) *HarnessEnhanced

func (*HarnessEnhanced) ErrIfNoHelm

func (th *HarnessEnhanced) ErrIfNoHelm() error

func (*HarnessEnhanced) ErrorFromLoadAndRunTransformer

func (th *HarnessEnhanced) ErrorFromLoadAndRunTransformer(
    config, input string) error

func (*HarnessEnhanced) GetPluginConfig

func (th *HarnessEnhanced) GetPluginConfig() *types.PluginConfig

func (*HarnessEnhanced) GetRoot

func (th *HarnessEnhanced) GetRoot() string

func (*HarnessEnhanced) LoadAndRunGenerator

func (th *HarnessEnhanced) LoadAndRunGenerator(
    config string) resmap.ResMap

func (*HarnessEnhanced) LoadAndRunGeneratorWithBuildAnnotations

func (th *HarnessEnhanced) LoadAndRunGeneratorWithBuildAnnotations(
    config string) resmap.ResMap

func (*HarnessEnhanced) LoadAndRunTransformer

func (th *HarnessEnhanced) LoadAndRunTransformer(
    config, input string) resmap.ResMap

func (*HarnessEnhanced) MkDir

func (th *HarnessEnhanced) MkDir(path string) string

func (*HarnessEnhanced) PrepBuiltin

func (th *HarnessEnhanced) PrepBuiltin(k string) *HarnessEnhanced

func (*HarnessEnhanced) PrepExecPlugin

func (th *HarnessEnhanced) PrepExecPlugin(g, v, k string) *HarnessEnhanced

func (*HarnessEnhanced) Reset

func (th *HarnessEnhanced) Reset()

func (*HarnessEnhanced) ResetLoaderRoot

func (th *HarnessEnhanced) ResetLoaderRoot(root string)

ResetLoaderRoot interprets its argument as an absolute directory path. It creates the directory, and creates the harness's file loader rooted in that directory.

func (*HarnessEnhanced) RunTransformer

func (th *HarnessEnhanced) RunTransformer(
    config, input string) (resmap.ResMap, error)

func (*HarnessEnhanced) RunTransformerAndCheckError

func (th *HarnessEnhanced) RunTransformerAndCheckError(
    config, input string, assertFn AssertFunc)

func (*HarnessEnhanced) RunTransformerAndCheckResult

func (th *HarnessEnhanced) RunTransformerAndCheckResult(
    config, input, expected string)

func (*HarnessEnhanced) RunTransformerFromResMap

func (th *HarnessEnhanced) RunTransformerFromResMap(
    config string, resMap resmap.ResMap) (resmap.ResMap, error)