...

Package testing

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

Overview ▾

Variables

APIVersionRegexp is the regular expression that matches with valid apiversion

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

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

type ComponentConfigPackage

ComponentConfigPackage is used in APIGroup Testing

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
}

type TestCase

TestCase defines a testcase for roundtrip and defaulting tests

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

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