jx: github.com/jenkins-x/jx/pkg/cmd/testhelpers Index | Files

package testhelpers

import "github.com/jenkins-x/jx/pkg/cmd/testhelpers"

Index

Package Files

app_test_helpers.go cmd_test_helpers.go

func AssertAllPromoteStepsSuccessful Uses

func AssertAllPromoteStepsSuccessful(t *testing.T, activities typev1.PipelineActivityInterface, name string)

func AssertHasNoPullRequestForEnv Uses

func AssertHasNoPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, envName string)

func AssertHasPipelineStatus Uses

func AssertHasPipelineStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, status v1.ActivityStatusType)

func AssertHasPromoteStatus Uses

func AssertHasPromoteStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, envName string, status v1.ActivityStatusType)

func AssertHasPullRequestForEnv Uses

func AssertHasPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, envName string)

func AssertPromoteStep Uses

func AssertPromoteStep(t *testing.T, step *v1.WorkflowStep, expectedEnvironment string)

func AssertSetPullRequestComplete Uses

func AssertSetPullRequestComplete(t *testing.T, provider *gits.FakeProvider, repository *gits.FakeRepository, prNumber int) bool

func AssertSetPullRequestMerged Uses

func AssertSetPullRequestMerged(t *testing.T, provider *gits.FakeProvider, orgName string, repositoryName string,
    prNumber int) bool

AssertSetPullRequestMerged validates that the fake PR has merged

func AssertWorkflowStatus Uses

func AssertWorkflowStatus(t *testing.T, activities typev1.PipelineActivityInterface, name string, status v1.ActivityStatusType)

func CleanupTestEnvironmentDir Uses

func CleanupTestEnvironmentDir(o *opts.CommonOptions) error

CleanupTestEnvironmentDir should be called in a deferred function whenever CreateTestEnvironmentDir is called

func CleanupTestJxHomeDir Uses

func CleanupTestJxHomeDir(originalDir, tempDir string) error

CleanupTestJxHomeDir should be called in a deferred function whenever CreateTestJxHomeDir is called

func CleanupTestKubeConfigDir Uses

func CleanupTestKubeConfigDir(originalFile, tempDir string) error

CleanupTestKubeConfigDir should be called in a deferred function whenever CreateTestKubeConfigDir is called

func ConfigureTestOptions Uses

func ConfigureTestOptions(o *opts.CommonOptions, git gits.Gitter, helm helm.Helmer)

ConfigureTestOptions lets configure the options for use in tests using fake APIs to k8s cluster

func ConfigureTestOptionsWithResources Uses

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 Uses

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 Uses

func CreateTestJxHomeDir() (string, string, error)

CreateTestJxHomeDir creates a temporary JX_HOME directory for the tests, copying over any existing config, returning the original JX_HOME directory, the temporary JX_HOME value, and any error.

func CreateTestKubeConfigDir Uses

func CreateTestKubeConfigDir() (string, string, error)

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 Uses

func CreateTestPipelineActivity(jxClient versioned.Interface, ns string, folder string, repo string, branch string, build string, workflow string) (*v1.PipelineActivity, error)

func MockFactoryFakeClients Uses

func MockFactoryFakeClients(mockFactory *clients_test.MockFactory)

MockFactoryFakeClients lets add the fake k8s clients to the factory

func MockFactoryWithKubeClients Uses

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 SetFakeFactoryFromKubeClients Uses

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 Uses

func SetPullRequestClosed(pr *gits.FakePullRequest)

func SetSuccessCommitStatusInPR Uses

func SetSuccessCommitStatusInPR(t *testing.T, repository *gits.FakeRepository, prNumber int)

func WaitForPullRequestForEnv Uses

func WaitForPullRequestForEnv(t *testing.T, activities typev1.PipelineActivityInterface, name string, envName string)

type AppTestOptions Uses

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 Uses

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 Uses

func (o *AppTestOptions) AddApp(values map[string]interface{}, prefix string) (string, string, string, error)

DirectlyAddApp adds a dummy app using helm

func (*AppTestOptions) Cleanup Uses

func (o *AppTestOptions) Cleanup() error

Cleanup must be run in a defer statement whenever CreateAppTestOptions is run

func (*AppTestOptions) DirectlyAddAppToGitOps Uses

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 Uses

func (o *AppTestOptions) GetFullDevEnvDir(envDir string) (name string)

GetFullDevEnvDir returns a dev environment including org name and env

Package testhelpers imports 42 packages (graph). Updated 2019-09-10. Refresh now. Tools for package owners.