diff --git a/helm_test.go b/helm_test.go new file mode 100644 index 000000000..e24e9ed3d --- /dev/null +++ b/helm_test.go @@ -0,0 +1,42 @@ +package main + +import ( + "testing" + + coreTests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" + "github.com/jfrog/jfrog-cli/utils/tests" +) + +var ( + helmCli *coreTests.JfrogCli +) + +func InitHelmTests() { + initArtifactoryCli() + initHelmCli() + cleanUpOldBuilds() + cleanUpOldRepositories() + tests.AddTimestampToGlobalVars() + createRequiredRepos() +} + +func CleanHelmTests() { + deleteCreatedRepos() +} + +func initHelmCli() { + if helmCli != nil { + return + } + helmCli = coreTests.NewJfrogCli(execMain, "jfrog", authenticate(false)) +} + +func initHelmTest(t *testing.T) { + if !*tests.TestHelm { + t.Skip("Skipping Helm test. To run Helm test add the '-test.helm=true' option.") + } +} + +func TestHelmExample(t *testing.T) { + initHelmTest(t) +} diff --git a/main_test.go b/main_test.go index d4f057028..9b31dc029 100644 --- a/main_test.go +++ b/main_test.go @@ -83,6 +83,9 @@ func setupIntegrationTests() { if *tests.TestEvidence { InitEvidenceTests() } + if *tests.TestHelm { + InitHelmTests() + } } func tearDownIntegrationTests() { @@ -107,6 +110,9 @@ func tearDownIntegrationTests() { if *tests.TestEvidence { CleanEvidenceTests() } + if *tests.TestHelm { + CleanHelmTests() + } } func InitBuildToolsTests() { @@ -190,7 +196,7 @@ func initArtifactoryCli() { *tests.JfrogUrl = utils.AddTrailingSlashIfNeeded(*tests.JfrogUrl) artifactoryCli = coreTests.NewJfrogCli(execMain, "jfrog rt", authenticate(false)) if (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestPlugins || *tests.TestArtifactoryProject || - *tests.TestAccess || *tests.TestTransfer || *tests.TestLifecycle { + *tests.TestAccess || *tests.TestTransfer || *tests.TestLifecycle || *tests.TestHelm { configCli = createConfigJfrogCLI(authenticate(true)) platformCli = coreTests.NewJfrogCli(execMain, "jfrog", authenticate(false)) } diff --git a/utils/tests/utils.go b/utils/tests/utils.go index b2fee6e5f..9bf6e033c 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -74,6 +74,7 @@ var ( TestTransfer *bool TestLifecycle *bool TestEvidence *bool + TestHelm *bool HideUnitTestLog *bool ciRunId *string InstallDataTransferPlugin *bool @@ -111,6 +112,7 @@ func init() { TestTransfer = flag.Bool("test.transfer", false, "Test files transfer") TestLifecycle = flag.Bool("test.lifecycle", false, "Test lifecycle") TestEvidence = flag.Bool("test.evidence", false, "Test evidence") + TestHelm = flag.Bool("test.helm", false, "Test Helm") ContainerRegistry = flag.String("test.containerRegistry", "localhost:8082", "Container registry") HideUnitTestLog = flag.Bool("test.hideUnitTestLog", false, "Hide unit tests logs and print it in a file") InstallDataTransferPlugin = flag.Bool("test.installDataTransferPlugin", false, "Install data-transfer plugin on the source Artifactory server") @@ -348,6 +350,7 @@ func GetNonVirtualRepositories() map[*string]string { TestAccess: {&RtRepo1}, TestTransfer: {&RtRepo1, &RtRepo2, &MvnRepo1, &MvnRemoteRepo, &DockerRemoteRepo}, TestLifecycle: {&RtDevRepo, &RtProdRepo1, &RtProdRepo2}, + TestHelm: {&RtRepo1}, } return getNeededRepositories(nonVirtualReposMap) } @@ -371,6 +374,7 @@ func GetVirtualRepositories() map[*string]string { TestPlugins: {}, TestXray: {&GoVirtualRepo}, TestAccess: {}, + TestHelm: {}, } return getNeededRepositories(virtualReposMap) } @@ -409,6 +413,7 @@ func GetBuildNames() []string { TestAccess: {}, TestTransfer: {&MvnBuildName}, TestLifecycle: {&LcBuildName1, &LcBuildName2, &LcBuildName3}, + TestHelm: {}, } return getNeededBuildNames(buildNamesMap) }