test

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSchemasToStore added in v0.11.0

func AddSchemasToStore(t *testing.T, dir string, ms storage.MutableStore)

func DataFS added in v0.12.0

func DataFS() fs.FS

func ExtractTxtArchiveToDir added in v0.30.0

func ExtractTxtArchiveToDir(t *testing.T, path, out string)

func ExtractTxtArchiveToFS added in v0.30.0

func ExtractTxtArchiveToFS(t *testing.T, path string) fs.FS

func FilterPolicies added in v0.29.0

func FilterPolicies[P *policyv1.Policy | policy.Wrapper](t *testing.T, policies []P, params storage.ListPolicyIDsParams) []P

func FindPolicyFiles added in v0.11.0

func FindPolicyFiles(t *testing.T, dir string, callback func(string) error) error

func LoadPolicy added in v0.11.0

func LoadPolicy(t *testing.T, path string) *policyv1.Policy

func PathToDir added in v0.11.0

func PathToDir(tb testing.TB, dir string) string

func ReadSchemaFromFS added in v0.11.0

func ReadSchemaFromFS(t *testing.T, fsys fs.FS, path string) []byte

func ReadSchemaFromFile added in v0.11.0

func ReadSchemaFromFile(t *testing.T, path string) []byte

func RenderTemplate added in v0.12.0

func RenderTemplate(tb testing.TB, path string, data any) []byte

func SkipIfGHActions added in v0.11.0

func SkipIfGHActions(t *testing.T)

func TemplateFuncs

func TemplateFuncs() template.FuncMap

func WriteGoldenFile added in v0.30.0

func WriteGoldenFile(t *testing.T, path string, contents proto.Message)

Types

type Case added in v0.11.0

type Case struct {
	Want       map[string][]byte
	Name       string
	SourceFile string
	Input      []byte
}

func LoadTestCases added in v0.11.0

func LoadTestCases(tb testing.TB, subDir string) []Case

LoadTestCases loads groups of test files from the given path. Consider a directory containing the following set of files: |- test01.yaml |- test01.yaml.err |- test01.yaml.out

The above files will be converted to a Case object as follows:

Case {
  Name: "test01",
  Input: <contents_of_test01.yaml>,
  Want: map[string][]byte{
    "err": <contents_of_test01.yaml.err>,
    "out": <contents_of_test01.yaml.out>,
  }
}.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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