component-basek8s.io/component-base/config/testing Index | Files

package testing

import "k8s.io/component-base/config/testing"

Index

Variables

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

Source Files

apigroup.go defaulting.go helpers.go roundtrip.go

Version
v0.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
16 packages
Last checked
1 hour ago

Tools for package owners.