testing

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestLeaseDurationSeconds int32 = 1
	TestManagedClusterName         = "testmanagedcluster"
)

Variables

This section is empty.

Functions

func AssertActions

func AssertActions(t *testing.T, actualActions []clienttesting.Action, expectedVerbs ...string)

AssertActions asserts the actual actions have the expected action verb

func AssertCSRCondition

func AssertCSRCondition(
	t *testing.T,
	actualConditions []certv1.CertificateSigningRequestCondition,
	expectedCondition certv1.CertificateSigningRequestCondition)

AssertCSRCondition asserts the actual csr conditions has the expected condition

func AssertCondition added in v0.8.0

func AssertCondition(
	t *testing.T,
	actualConditions []metav1.Condition,
	expectedCondition metav1.Condition)

AssertCondition asserts the actual conditions has the expected condition

func AssertError

func AssertError(t *testing.T, actual error, expectedErr string)

AssertError asserts the actual error representation is the same with the expected, if the expected error representation is empty, the actual should be nil

func AssertErrorWithPrefix

func AssertErrorWithPrefix(t *testing.T, actual error, expectedErrorPrefix string)

AssertError asserts the actual error representation starts with the expected prerfix, if the expected error prefix is empty, the actual should be nil

func AssertFileContent

func AssertFileContent(t *testing.T, filePath string, expectedContent []byte)

AssertFileContent asserts a given file content

func AssertFileExist

func AssertFileExist(t *testing.T, filePath string)

AssertFileExist asserts a given file exists

func AssertFinalizers

func AssertFinalizers(t *testing.T, obj runtime.Object, finalizers []string)

AssertFinalizers asserts the given runtime object has the expected finalizers

func AssertLeaseUpdated

func AssertLeaseUpdated(t *testing.T, lease, lastLease *coordinationv1.Lease)

AssertLeaseUpdated asserts the lease obj is updated

func AssertManagedClusterClientConfigs

func AssertManagedClusterClientConfigs(t *testing.T, actual, expected []clusterv1.ClientConfig)

AssertManagedClusterClientConfigs asserts the actual managed cluster client configs are the same wiht the expected

func AssertManagedClusterStatus

func AssertManagedClusterStatus(t *testing.T, actual, expected clusterv1.ManagedClusterStatus)

AssertManagedClusterStatus sserts the actual managed cluster status is the same wiht the expected

func AssertNoActions

func AssertNoActions(t *testing.T, actualActions []clienttesting.Action)

AssertNoActions asserts no actions are happened

func AssertNoMoreUpdates

func AssertNoMoreUpdates(t *testing.T, actions []clienttesting.Action)

AssertNoMoreUpdates asserts only one update action in given actions

func AssertSubjectAccessReviewObj

func AssertSubjectAccessReviewObj(t *testing.T, actual runtime.Object)

AssertSubjectAccessReviewObj asserts the given runtime object is the authorization SubjectAccessReview object

func AssertUpdateActions

func AssertUpdateActions(t *testing.T, actions []clienttesting.Action)

AssertUpdateActions asserts the actions are get-then-update action

func AssertV1beta1CSRCondition added in v0.8.0

func AssertV1beta1CSRCondition(
	t *testing.T,
	actualConditions []certv1beta1.CertificateSigningRequestCondition,
	expectedCondition certv1beta1.CertificateSigningRequestCondition)

AssertV1beta1CSRCondition asserts the actual csr conditions has the expected condition

func NewAcceptedManagedCluster

func NewAcceptedManagedCluster() *clusterv1.ManagedCluster

func NewAcceptingManagedCluster

func NewAcceptingManagedCluster() *clusterv1.ManagedCluster

func NewAddOnLease

func NewAddOnLease(namespace, name string, renewTime time.Time) *coordv1.Lease

func NewApprovedCSR

func NewApprovedCSR(holder CSRHolder) *certv1.CertificateSigningRequest

func NewApprovedV1beta1CSR added in v0.8.0

func NewApprovedV1beta1CSR(holder CSRHolder) *certv1beta1.CertificateSigningRequest

func NewAvailableManagedCluster

func NewAvailableManagedCluster() *clusterv1.ManagedCluster

func NewCSR

func NewDeletingManagedCluster

func NewDeletingManagedCluster() *clusterv1.ManagedCluster

func NewDeniedCSR

func NewDeniedCSR(holder CSRHolder) *certv1.CertificateSigningRequest

func NewDeniedManagedCluster

func NewDeniedManagedCluster() *clusterv1.ManagedCluster

func NewDeniedV1beta1CSR added in v0.8.0

func NewDeniedV1beta1CSR(holder CSRHolder) *certv1beta1.CertificateSigningRequest

func NewHubKubeconfigSecret

func NewHubKubeconfigSecret(namespace, name, resourceVersion string, cert *TestCert, data map[string][]byte) *corev1.Secret

func NewJoinedManagedCluster

func NewJoinedManagedCluster() *clusterv1.ManagedCluster

func NewKubeconfig

func NewKubeconfig(key, cert []byte) []byte

func NewManagedCluster

func NewManagedCluster() *clusterv1.ManagedCluster

func NewManagedClusterCondition

func NewManagedClusterCondition(name, status, reason, message string, lastTransition *metav1.Time) metav1.Condition

func NewManagedClusterLease

func NewManagedClusterLease(name string, renewTime time.Time) *coordv1.Lease

func NewManagedClusterWithStatus

func NewManagedClusterWithStatus(capacity, allocatable corev1.ResourceList) *clusterv1.ManagedCluster

func NewManifestWork

func NewManifestWork(namespace, name string, finalizers []string, deletionTimestamp *metav1.Time) *workapiv1.ManifestWork

func NewNamespace

func NewNamespace(name string, terminated bool) *corev1.Namespace

func NewNode

func NewNode(name string, capacity, allocatable corev1.ResourceList) *corev1.Node

func NewResourceList

func NewResourceList(cpu, mem int) corev1.ResourceList

func NewRole

func NewRole(namespace, name string, finalizers []string, terminated bool) *rbacv1.Role

func NewRoleBinding

func NewRoleBinding(namespace, name string, finalizers []string, terminated bool) *rbacv1.RoleBinding

func NewUnAvailableManagedCluster added in v0.7.0

func NewUnAvailableManagedCluster() *clusterv1.ManagedCluster

func NewUnknownManagedCluster

func NewUnknownManagedCluster() *clusterv1.ManagedCluster

func NewUnstructuredObj

func NewUnstructuredObj(apiVersion, kind, namespace, name string) *unstructured.Unstructured

func NewV1beta1CSR added in v0.8.0

func NewV1beta1CSR(holder CSRHolder) *certv1beta1.CertificateSigningRequest

func WriteFile

func WriteFile(filename string, data []byte)

Types

type CSRHolder

type CSRHolder struct {
	Name         string
	Labels       map[string]string
	SignerName   string
	CN           string
	Orgs         []string
	Username     string
	ReqBlockType string
}

type FakeSyncContext

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

func NewFakeSyncContext

func NewFakeSyncContext(t *testing.T, clusterName string) *FakeSyncContext

func (FakeSyncContext) Queue

func (FakeSyncContext) QueueKey

func (f FakeSyncContext) QueueKey() string

func (FakeSyncContext) Recorder

func (f FakeSyncContext) Recorder() events.Recorder

type TestCert

type TestCert struct {
	Cert []byte
	Key  []byte
}

func NewTestCert

func NewTestCert(commonName string, duration time.Duration) *TestCert

func NewTestCertWithSubject

func NewTestCertWithSubject(subject pkix.Name, duration time.Duration) *TestCert

Jump to

Keyboard shortcuts

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