test

package
v0.0.0-...-fe45be7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 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, banReason string)

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 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 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 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 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 HostKubeConfig

func HostKubeConfig() *clientcmdapi.Config

func MemberKubeConfig

func MemberKubeConfig() *clientcmdapi.Config

func NewCommandCreator

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

func NewFakeClients

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

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 PersistKubeConfigFile

func PersistKubeConfigFile(t *testing.T, config *clientcmdapi.Config) string

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 Users

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

Types

type ArgsAssertion

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

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, options ...MemberClusterOption) 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 MemberClusterOption

type MemberClusterOption func(*assets.MemberCluster)

func WithSeparateKustomizeComponent

func WithSeparateKustomizeComponent() MemberClusterOption

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

func (ServiceAccountCreator) WithSelectedMembers

func (c ServiceAccountCreator) WithSelectedMembers(members ...string) ServiceAccountCreator

func (ServiceAccountCreator) WithSkippedMembers

func (c ServiceAccountCreator) WithSkippedMembers(members ...string) 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, allCluster bool, group string, permissions ...PermissionsPerClusterTypeModifier) UserCreator

func (UserCreator) WithSelectedMembers

func (c UserCreator) WithSelectedMembers(members ...string) UserCreator

func (UserCreator) WithSkippedMembers

func (c UserCreator) WithSkippedMembers(members ...string) UserCreator

type UserSignupModifier

type UserSignupModifier func(userSignup *toolchainv1alpha1.UserSignup)

func UserSignupApprovedByAdmin

func UserSignupApprovedByAdmin(_ bool) UserSignupModifier

func UserSignupAutomaticallyApproved

func UserSignupAutomaticallyApproved(_ bool) UserSignupModifier

func UserSignupDeactivated

func UserSignupDeactivated(deactivated bool) UserSignupModifier

func UserSignupRemoveLabel

func UserSignupRemoveLabel(key string) UserSignupModifier

Jump to

Keyboard shortcuts

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