test

package
v0.0.0-...-4e12832 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertBannedUser

func AssertBannedUser(t *testing.T, fakeClient *test.FakeClient, userSignup *toolchainv1alpha1.UserSignup)

func AssertCatalogSourceDoesNotExist

func AssertCatalogSourceDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertCatalogSourceDoesNotExist verifies that there is no CatalogSource resource with the given namespace/name

func AssertCatalogSourceExists

func AssertCatalogSourceExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertCatalogSourceExists verifies that the there is a CatalogSource resource matching the expected namespace/name

func AssertCatalogSourceHasSpec

func AssertCatalogSourceHasSpec(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected olmv1alpha1.CatalogSourceSpec)

AssertCatalogSourceHasSpec verifies that the there is a CatalogSource resource matching the expected namespace/name, and with the same specs.

func AssertConfigMapDoesNotExist

func AssertConfigMapDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertConfigMapDoesNotExist verifies that there is no ConfigMap resource with the given namespace/name

func AssertConfigMapExists

func AssertConfigMapExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertConfigMapExists verifies that the there is a ConfigMap resource matching the expected namespace/name

func AssertConfigMapHasData

func AssertConfigMapHasData(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected map[string]string)

AssertConfigMapHasData verifies that the there is a ConfigMap resource matching the expected namespace/name, and with the same data.

func AssertConfigMapHasDataEntries

func AssertConfigMapHasDataEntries(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expectedEntries ...string)

AssertConfigMapHasDataEntries verifies that the there is a ConfigMap resource matching the expected namespace/name, and with the given entries in its `data`.

func AssertDeploymentHasReplicas

func AssertDeploymentHasReplicas(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, replicas int32)

AssertDeploymentHasReplicas verifies that the there is a Deployment resource matching the expected namespace/name, and with the same spec.replicas.

func AssertNoBannedUser

func AssertNoBannedUser(t *testing.T, fakeClient *test.FakeClient, userSignup *toolchainv1alpha1.UserSignup)

func AssertObjectDoesNotExist

func AssertObjectDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, resource runtimeclient.Object)

AssertObjectDoesNotExist verifies that there is no resource of the given type and with the given namespace/name

func AssertObjectExists

func AssertObjectExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, resource runtimeclient.Object)

AssertObjectExists verifies that there is a resource of the given type and with the given namespace/name

func AssertObjectHasContent

func AssertObjectHasContent(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, actualResource runtimeclient.Object, contentAssertions ...func())

AssertObjectHasContent verifies that the there is a resource matching the expected namespace/name, and with the same specs.

func AssertObjects

func AssertObjects(t *testing.T, fakeClient *test.FakeClient, objectAssertions ...ObjectAssertion)

AssertObjects executes all given object assertions

func AssertOperatorGroupDoesNotExist

func AssertOperatorGroupDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertOperatorGroupDoesNotExist verifies that there is no OperatorGroup resource with the given namespace/name

func AssertOperatorGroupExists

func AssertOperatorGroupExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertOperatorGroupExists verifies that the there is a OperatorGroup resource matching the expected namespace/name

func AssertOperatorGroupHasLabels

func AssertOperatorGroupHasLabels(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected map[string]string)

func AssertOperatorGroupHasSpec

func AssertOperatorGroupHasSpec(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected olmv1.OperatorGroupSpec)

AssertOperatorGroupHasSpec verifies that the there is an OperatorGroup resource matching the expected namespace/name, and with the same specs.

func AssertSecretDoesNotExist

func AssertSecretDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertSecretDoesNotExist verifies that there is no Secret resource with the given namespace/name

func AssertSecretExists

func AssertSecretExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertSecretExists verifies that the there is a Secret resource matching the expected namespace/name

func AssertSecretHasData

func AssertSecretHasData(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected map[string][]byte)

AssertSecretHasData verifies that the there is a Secret resource matching the expected namespace/name, and with the same data.

func AssertSecretHasDataEntries

func AssertSecretHasDataEntries(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expectedEntries ...string) map[string][]byte

AssertSecretHasDataEntries verifies that the there is a Secret resource matching the expected namespace/name, and with the given entries in its `data`.

func AssertServiceAccountHasImagePullSecret

func AssertServiceAccountHasImagePullSecret(t *testing.T, fakeClient runtimeclient.Client, saNamespacedName types.NamespacedName, secretName string)

func AssertSubscriptionDoesNotExist

func AssertSubscriptionDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertSubscriptionDoesNotExist verifies that there is no Subscription resource with the given namespace/name

func AssertSubscriptionExists

func AssertSubscriptionExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertSubscriptionExists verifies that the there is a Subscription resource matching the expected namespace/name

func AssertSubscriptionHasSpec

func AssertSubscriptionHasSpec(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected *olmv1alpha1.SubscriptionSpec)

AssertSubscriptionHasSpec verifies that the there is a Subscription resource matching the expected namespace/name, and with the same specs.

func AssertToolchainClusterDoesNotExist

func AssertToolchainClusterDoesNotExist(t *testing.T, fakeClient *test.FakeClient, toolchainCluster *toolchainv1alpha1.ToolchainCluster)

func AssertToolchainClusterSpec

func AssertToolchainClusterSpec(t *testing.T, fakeClient *test.FakeClient, expectedToolchainCluster *toolchainv1alpha1.ToolchainCluster)

func AssertToolchainConfigDoesNotExist

func AssertToolchainConfigDoesNotExist(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertToolchainConfigDoesNotExist verifies that there is no ToolchainConfig resource with the given namespace/name

func AssertToolchainConfigExists

func AssertToolchainConfigExists(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName)

AssertToolchainConfigExists verifies that the there is an ToolchainConfig resource matching the expected namespace/name

func AssertToolchainConfigHasSpec

func AssertToolchainConfigHasSpec(t *testing.T, fakeClient runtimeclient.Client, namespacedName types.NamespacedName, expected toolchainv1alpha1.ToolchainConfigSpec)

AssertToolchainConfigHasSpec verifies that there is an ToolchainConfig resource matching the expected namespace/name, and with the same spec.

func AssertUserSignupDoesNotExist

func AssertUserSignupDoesNotExist(t *testing.T, fakeClient *test.FakeClient, userSignup *toolchainv1alpha1.UserSignup)

func AssertUserSignupSpec

func AssertUserSignupSpec(t *testing.T, fakeClient *test.FakeClient, expectedUserSignup *toolchainv1alpha1.UserSignup)

func ClusterRolesBindings

func ClusterRolesBindings(namespacePermissionsPerClusterType assets.PermissionsPerClusterType, clusterType configuration.ClusterType, clusterRoles ...string)

func NewCommandCreator

func NewCommandCreator(t *testing.T, cmd string, expCmd string, assertArgs ArgsAssertion) client.CommandCreator

func NewFakeClients

func NewFakeClients(t *testing.T, initObjs ...runtime.Object) (clicontext.NewClientFunc, *test.FakeClient)

func NewFakeExternalClient

func NewFakeExternalClient(t *testing.T, token string, apiEndpoint string) *rest.RESTClient

func NewFakeFiles

func NewFakeFiles(t *testing.T, fakeFiles ...FakeFileCreator) assets.FS

func NewKsctlConfig

func NewKsctlConfig(clusterDefs ...ClusterDefinitionWithName) configuration.KsctlConfig

NewKsctlConfig creates KsctlConfig object with the given cluster definitions

func NewKubeSawAdmins

func NewKubeSawAdmins(addClusters ClustersCreator, serviceAccounts []assets.ServiceAccount, users []assets.User) *assets.KubeSawAdmins

func NewUserSignup

func NewUserSignup(modifiers ...UserSignupModifier) *toolchainv1alpha1.UserSignup

func RoleBindings

func RoleBindings(namespacePermissionsPerClusterType assets.PermissionsPerClusterType, clusterType configuration.ClusterType, namespace string, modifiers ...RoleBindingsModifier)

func ServiceAccounts

func ServiceAccounts(serviceAccountModifiers ...ServiceAccountCreator) []assets.ServiceAccount

func SetFileConfig

func SetFileConfig(t *testing.T, clusterDefs ...ClusterDefinitionWithName)

SetFileConfig generates the configuration file to use during a test The file is automatically cleanup at the end of the test.

func UserSignupCompleteCondition

func UserSignupCompleteCondition(status corev1.ConditionStatus, reason string) toolchainv1alpha1.Condition

func Users

func Users(userCreators ...UserCreator) []assets.User

Types

type ArgsAssertion

type ArgsAssertion func(*testing.T, ...string)

func AssertArgsEqual

func AssertArgsEqual(expArgs ...string) ArgsAssertion

func AssertFirstArgPrefixRestEqual

func AssertFirstArgPrefixRestEqual(firstArgPrefix string, toEqual ...string) ArgsAssertion

type ClusterDefinitionWithName

type ClusterDefinitionWithName struct {
	configuration.ClusterAccessDefinition
	ClusterName string
}

func Host

func Host(options ...ConfigOption) ClusterDefinitionWithName

Host defines the configuration for the host cluster

func Member

func Member(options ...ConfigOption) ClusterDefinitionWithName

Member defines the configuration for a member cluster

func WithValues

func WithValues(clusterDef ClusterDefinitionWithName, options ...ConfigOption) ClusterDefinitionWithName

WithValues applies the options on the given parameters

type ClustersCreator

type ClustersCreator func(*assets.Clusters)

func Clusters

func Clusters(hostURL string) ClustersCreator

func (ClustersCreator) AddMember

func (m ClustersCreator) AddMember(name, URL string) ClustersCreator

type ConfigOption

type ConfigOption func(*ClusterDefinitionWithName)

ConfigOption an option on the configuration generated for a test

func ClusterName

func ClusterName(clusterName string) ConfigOption

ClusterName specifies the name of the server (default is `host` or `member1`)

func ClusterType

func ClusterType(clusterType string) ConfigOption

ClusterType specifies the cluster type (`host` or `member`)

func NoToken

func NoToken() ConfigOption

NoToken deletes the default token set for the cluster

func ServerAPI

func ServerAPI(serverAPI string) ConfigOption

ServerAPI specifies the ServerAPI to use (default is `https://cool-server.com`)

func ServerName

func ServerName(serverName string) ConfigOption

ServerName specifies the name of the server (default is `cool-server.com`)

type FakeFileCreator

type FakeFileCreator func(t *testing.T) (string, []byte)

func FakeFile

func FakeFile(path string, content []byte) FakeFileCreator

func FakeTemplate

func FakeTemplate(path string, objects ...runtime.Object) FakeFileCreator

func FakeTemplateWithParams

func FakeTemplateWithParams(path string, requiredParams []string, objects ...runtime.Object) FakeFileCreator

type FakeTerminal

type FakeTerminal struct {
	ioutils.Terminal
	// contains filtered or unexported fields
}

FakeTerminal a fake terminal, which can: - be configured to always return the same response when the command prompts the user for confirmation - capture the command output

func NewFakeTerminal

func NewFakeTerminal() *FakeTerminal

NewFakeTerminal returns a new FakeTerminal which will only print messages in the console

func NewFakeTerminalWithResponse

func NewFakeTerminalWithResponse(response string) *FakeTerminal

NewFakeTerminalWithResponse returns a new FakeTerminal which will print messages in the console and respond to the questions/confirmations with the given response

func (*FakeTerminal) Output

func (t *FakeTerminal) Output() string

Output return the content of the output buffer

func (*FakeTerminal) Tee

func (t *FakeTerminal) Tee(out io.Writer)

Tee uses the given `out` as a secondary output. Usage: `Tee(os.Stdout)` to see in the console what's record in this terminal during the tests Note: it should be configured at the beginning of a test

type ObjectAssertion

type ObjectAssertion func(t *testing.T, fakeClient *test.FakeClient)

ObjectAssertion is a type of function that should assert a content of an object

func ObjectDoesNotExists

func ObjectDoesNotExists(namespace, name string, actualResource runtimeclient.Object) ObjectAssertion

ObjectDoesNotExists checks that the given object does not exist

func ObjectExists

func ObjectExists(namespace, name string, actualResource runtimeclient.Object, contentAssertion func(t *testing.T)) ObjectAssertion

ObjectExists checks that the given object exists and executes the given content assertion

type PermissionsPerClusterTypeModifier

type PermissionsPerClusterTypeModifier func(assets.PermissionsPerClusterType)

func HostClusterRoleBindings

func HostClusterRoleBindings(clusterRoles ...string) PermissionsPerClusterTypeModifier

func HostRoleBindings

func HostRoleBindings(namespace string, modifiers ...RoleBindingsModifier) PermissionsPerClusterTypeModifier

func MemberClusterRoleBindings

func MemberClusterRoleBindings(clusterRoles ...string) PermissionsPerClusterTypeModifier

func MemberRoleBindings

func MemberRoleBindings(namespace string, modifiers ...RoleBindingsModifier) PermissionsPerClusterTypeModifier

type RoleBindingsModifier

type RoleBindingsModifier func(*assets.RoleBindings)

func ClusterRole

func ClusterRole(clusterRoles ...string) RoleBindingsModifier

func Role

func Role(roles ...string) RoleBindingsModifier

type ServiceAccountCreator

type ServiceAccountCreator func() assets.ServiceAccount

func Sa

func Sa(baseName, namespace string, permissions ...PermissionsPerClusterTypeModifier) ServiceAccountCreator

type ToolchainClusterModifier

type ToolchainClusterModifier func(toolchainCluster *toolchainv1alpha1.ToolchainCluster)

func ToolchainClusterName

func ToolchainClusterName(name string) ToolchainClusterModifier

type UserCreator

type UserCreator func() assets.User

func User

func User(name string, IDs []string, group string, permissions ...PermissionsPerClusterTypeModifier) UserCreator

type UserSignupModifier

type UserSignupModifier func(userSignup *toolchainv1alpha1.UserSignup)

func UserSignupApprovedByAdmin

func UserSignupApprovedByAdmin(_ bool) UserSignupModifier

func UserSignupAutomaticallyApproved

func UserSignupAutomaticallyApproved(_ bool) UserSignupModifier

func UserSignupCompliantUsername

func UserSignupCompliantUsername(username string) UserSignupModifier

func UserSignupDeactivated

func UserSignupDeactivated(deactivated bool) UserSignupModifier

func UserSignupRemoveLabel

func UserSignupRemoveLabel(key string) UserSignupModifier

func UserSignupSetLabel

func UserSignupSetLabel(key, value string) UserSignupModifier

func UserSignupStatusComplete

func UserSignupStatusComplete(status corev1.ConditionStatus, reason string) UserSignupModifier

func UserSignupTargetCluster

func UserSignupTargetCluster(cluster string) UserSignupModifier

Jump to

Keyboard shortcuts

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