Documentation ¶
Index ¶
- func AssertAllPromoteStepsSuccessful(t *testing.T, activities typev1.PipelineActivityInterface, name string)
- func AssertHasNoPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, ...)
- func AssertHasPipelineStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, ...)
- func AssertHasPromoteStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, ...)
- func AssertHasPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, ...)
- func AssertPromoteStep(t *testing.T, step *v1.WorkflowStep, expectedEnvironment string)
- func AssertSetPullRequestComplete(t *testing.T, provider *gits.FakeProvider, repository *gits.FakeRepository, ...) bool
- func AssertSetPullRequestMerged(t *testing.T, provider *gits.FakeProvider, orgName string, ...) bool
- func CleanupTestEnvironmentDir(o *opts.CommonOptions) error
- func CleanupTestJxHomeDir(originalDir, tempDir string) (err error)
- func CleanupTestKubeConfigDir(originalFile, tempDir string) error
- func ConfigureTestOptions(o *opts.CommonOptions, git gits.Gitter, helm helm.Helmer)
- func ConfigureTestOptionsWithResources(o *opts.CommonOptions, k8sObjects []runtime.Object, jxObjects []runtime.Object, ...)
- func CreateTestEnvironmentDir(o *opts.CommonOptions) error
- func CreateTestJxHomeDir() (string, string, error)
- func CreateTestKubeConfigDir() (string, string, error)
- func CreateTestPipelineActivity(jxClient versioned.Interface, ns string, folder string, repo string, ...) (*v1.PipelineActivity, error)
- func CreateTestPipelineActivityWithTime(jxClient versioned.Interface, ns string, folder string, repo string, ...) (*v1.PipelineActivity, error)
- func GetFreePort() (int, error)
- func LabelSelector(labels map[string]string) string
- func MockFactoryFakeClients(mockFactory *clients_test.MockFactory)
- func MockFactoryWithKubeClients(mockFactory *clients_test.MockFactory, o *opts.CommonOptions)
- func PortForward(namespace string, podName string, containerPort string, forwardPort string, ...) (chan struct{}, error)
- func SetFakeFactoryFromKubeClients(o *opts.CommonOptions)
- func SetPullRequestClosed(pr *gits.FakePullRequest)
- func SetSuccessCommitStatusInPR(t *testing.T, repository *gits.FakeRepository, prNumber int)
- func WaitForPod(pod *core_v1.Pod, namespace string, labels map[string]string, ...) error
- func WaitForPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, ...)
- type AppTestOptions
- func (o *AppTestOptions) AddApp(values map[string]interface{}, prefix string) (string, string, string, error)
- func (o *AppTestOptions) Cleanup() error
- func (o *AppTestOptions) DirectlyAddAppToGitOps(appName string, values map[string]interface{}, prefix string) (name string, alias string, version string, err error)
- func (o *AppTestOptions) GetFullDevEnvDir(envDir string) (name string)
- type FakeOut
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAllPromoteStepsSuccessful ¶
func AssertAllPromoteStepsSuccessful(t *testing.T, activities typev1.PipelineActivityInterface, name string)
func AssertHasPipelineStatus ¶
func AssertHasPipelineStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, status v1.ActivityStatusType)
func AssertHasPromoteStatus ¶
func AssertHasPromoteStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, envName string, status v1.ActivityStatusType)
func AssertPromoteStep ¶
func AssertPromoteStep(t *testing.T, step *v1.WorkflowStep, expectedEnvironment string)
func AssertSetPullRequestComplete ¶
func AssertSetPullRequestComplete(t *testing.T, provider *gits.FakeProvider, repository *gits.FakeRepository, prNumber int) bool
func AssertSetPullRequestMerged ¶
func AssertSetPullRequestMerged(t *testing.T, provider *gits.FakeProvider, orgName string, repositoryName string, prNumber int) bool
AssertSetPullRequestMerged validates that the fake PR has merged
func CleanupTestEnvironmentDir ¶
func CleanupTestEnvironmentDir(o *opts.CommonOptions) error
CleanupTestEnvironmentDir should be called in a deferred function whenever CreateTestEnvironmentDir is called
func CleanupTestJxHomeDir ¶
CleanupTestJxHomeDir should be called in a deferred function whenever CreateTestJxHomeDir is called
func CleanupTestKubeConfigDir ¶
CleanupTestKubeConfigDir should be called in a deferred function whenever CreateTestKubeConfigDir is called
func ConfigureTestOptions ¶
ConfigureTestOptions lets configure the options for use in tests using fake APIs to k8s cluster
func ConfigureTestOptionsWithResources ¶
func ConfigureTestOptionsWithResources(o *opts.CommonOptions, k8sObjects []runtime.Object, jxObjects []runtime.Object, git gits.Gitter, fakeGitProvider *gits.FakeProvider, helm helm.Helmer, resourcesInstaller resources.Installer)
ConfigureTestOptions lets configure the options for use in tests using fake APIs to k8s cluster.
func CreateTestEnvironmentDir ¶
func CreateTestEnvironmentDir(o *opts.CommonOptions) error
CreateTestEnvironmentDir will create a temporary environment dir for the tests, copying over any existing config, and updating CommonOptions.EnvironmentDir() - this is useful for testing git operations on the environments without clobbering the local environments and risking the cluster getting contaminated - use with gits.GitLocal
func CreateTestJxHomeDir ¶
CreateTestJxHomeDir creates a temporary JX_HOME directory for the tests, returning the original JX_HOME directory, the temporary JX_HOME value, and any error.
func CreateTestKubeConfigDir ¶
CreateTestKubeConfigDir creates a temporary KUBECONFIG directory for the tests, copying over any existing config, returning the original KUBECONFIG value, the temporary KUBECONFIG value, and any error.
func CreateTestPipelineActivity ¶
func CreateTestPipelineActivity(jxClient versioned.Interface, ns string, folder string, repo string, branch string, build string, workflow string) (*v1.PipelineActivity, error)
CreateTestPipelineActivity creates a PipelineActivity with the given arguments
func CreateTestPipelineActivityWithTime ¶
func CreateTestPipelineActivityWithTime(jxClient versioned.Interface, ns string, folder string, repo string, branch string, build string, workflow string, t metav1.Time) (*v1.PipelineActivity, error)
CreateTestPipelineActivityWithTime creates a PipelineActivity with the given timestamp and adds it to the list of activities
func GetFreePort ¶ added in v2.1.56
GetFreePort asks the kernel for a free open port that is ready to use.
func LabelSelector ¶ added in v2.1.56
LabelSelector builds a Kubernetes label selector from the specified map.
func MockFactoryFakeClients ¶
func MockFactoryFakeClients(mockFactory *clients_test.MockFactory)
MockFactoryFakeClients lets add the fake k8s clients to the factory
func MockFactoryWithKubeClients ¶
func MockFactoryWithKubeClients(mockFactory *clients_test.MockFactory, o *opts.CommonOptions)
MockFactoryWithKubeClients registers the fake clients with the mock factory so they return the same instances
func PortForward ¶ added in v2.1.56
func PortForward(namespace string, podName string, containerPort string, forwardPort string, factory clients.Factory) (chan struct{}, error)
PortForward port forwards the container port of the specified pod in the given namespace to the specified local forwarding port. The functions returns a stop channel to stop port forwarding.
func SetFakeFactoryFromKubeClients ¶
func SetFakeFactoryFromKubeClients(o *opts.CommonOptions)
SetFakeFactoryFromKubeClients registers a factory from the existing clients so that if a client is nilled we reuse the same one again
func SetPullRequestClosed ¶
func SetPullRequestClosed(pr *gits.FakePullRequest)
func SetSuccessCommitStatusInPR ¶
func SetSuccessCommitStatusInPR(t *testing.T, repository *gits.FakeRepository, prNumber int)
func WaitForPod ¶ added in v2.1.56
func WaitForPod(pod *core_v1.Pod, namespace string, labels map[string]string, timeout time.Duration, kubeClient kubernetes.Interface) error
WaitForPod waits for the specified duration for the given Pod to get into the 'Running' status.
Types ¶
type AppTestOptions ¶
type AppTestOptions struct { CommonOptions *opts.CommonOptions FakeGitProvider *gits.FakeProvider DevRepo *gits.FakeRepository DevEnvRepo *gits.FakeRepository OrgName string DevEnvRepoInfo *gits.GitRepository DevEnv *jenkinsv1.Environment MockHelmer *helm_test.MockHelmer MockFactory *cmd_test.MockFactory MockVaultClient *vault_test.MockClient OriginalJxHome string OriginalKubeCfg string TempJxHome string TempKubeCfg string }
AppTestOptions contains all useful data from the test environment initialized by `prepareInitialPromotionEnv`
func CreateAppTestOptions ¶
func CreateAppTestOptions(gitOps bool, appName string, t assert.TestingT) *AppTestOptions
CreateAppTestOptions configures the mock environment for running apps related tests If you use this function, then don't use t.Parallel
func (*AppTestOptions) AddApp ¶
func (o *AppTestOptions) AddApp(values map[string]interface{}, prefix string) (string, string, string, error)
DirectlyAddApp adds a dummy app using helm
func (*AppTestOptions) Cleanup ¶
func (o *AppTestOptions) Cleanup() error
Cleanup must be run in a defer statement whenever CreateAppTestOptions is run
func (*AppTestOptions) DirectlyAddAppToGitOps ¶
func (o *AppTestOptions) DirectlyAddAppToGitOps(appName string, values map[string]interface{}, prefix string) (name string, alias string, version string, err error)
DirectlyAddAppToGitOps modifies the environment git repo directly to add a dummy app
func (*AppTestOptions) GetFullDevEnvDir ¶
func (o *AppTestOptions) GetFullDevEnvDir(envDir string) (name string)
GetFullDevEnvDir returns a dev environment including org name and env
type FakeOut ¶
type FakeOut struct {
// contains filtered or unexported fields
}
FakeOut can be passed to the Common Options for ease of testing. It's also helpful so test output doesn't get polluted by all the printouts