testing

package
Version: v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIVersionRegexp = regexp.MustCompile(`^v\d+((alpha|beta){1}\d+)?$`)

APIVersionRegexp is the regular expression that matches with valid apiversion

Functions

func DefaultingTest

func DefaultingTest(t *testing.T, scheme *runtime.Scheme, codecs serializer.CodecFactory)

DefaultingTest run defaulting tests for given scheme

func RoundTripTest

func RoundTripTest(t *testing.T, scheme *runtime.Scheme, codecs serializer.CodecFactory)

RoundTripTest runs roundtrip tests for given scheme

func RunTestsOnYAMLData

func RunTestsOnYAMLData(t *testing.T, tests []TestCase)

RunTestsOnYAMLData decodes the yaml file from specified path, encodes the object and matches with expected yaml in specified path

func VerifyExternalTypePackage

func VerifyExternalTypePackage(pkginfo *ComponentConfigPackage) error

VerifyExternalTypePackage tests if external component config package is defined correctly Test tag naming (json name should match Go name) Test that GroupName has the k8s.io suffix Test that GroupName == SchemeGroupVersion.GroupName Test that the API version follows the right pattern and isn't internal Test that addKnownTypes and AddToScheme registers at least one type and doesn't error Test that the GroupName is named correctly (based on ComponentName), and there is a {Component}Configuration kind in the scheme

func VerifyInternalTypePackage

func VerifyInternalTypePackage(pkginfo *ComponentConfigPackage) error

VerifyInternalTypePackage tests if internal component config package is defined correctly Test tag naming (no tags allowed) Test that GroupName has the k8s.io suffix Test that GroupName == SchemeGroupVersion.GroupName API version should be internal Test that addKnownTypes and AddToScheme registers at least one type and doesn't error Test that the GroupName is named correctly (based on ComponentName), and there is a {Component}Configuration kind in the scheme

Types

type ComponentConfigPackage

type ComponentConfigPackage struct {
	ComponentName               string
	GroupName                   string
	SchemeGroupVersion          schema.GroupVersion
	AddToScheme                 func(*runtime.Scheme) error
	SkipTests                   sets.String
	AllowedTags                 map[reflect.Type]bool
	AllowedNonstandardJSONNames map[reflect.Type]string
}

ComponentConfigPackage is used in APIGroup Testing

type TestCase

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

TestCase defines a testcase for roundtrip and defaulting tests

func GetDefaultingTestCases

func GetDefaultingTestCases(t *testing.T, scheme *runtime.Scheme, codecs serializer.CodecFactory) []TestCase

GetDefaultingTestCases returns defaulting testcases for given scheme

func GetRoundtripTestCases

func GetRoundtripTestCases(t *testing.T, scheme *runtime.Scheme, codecs serializer.CodecFactory) []TestCase

GetRoundtripTestCases returns the testcases for roundtrip testing for given scheme

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL