diff --git a/main_test.go b/main_test.go index 41805010a..f9d4fb07b 100644 --- a/main_test.go +++ b/main_test.go @@ -55,7 +55,7 @@ func setupIntegrationTests() { if (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject { InitArtifactoryTests() } - if *tests.TestNpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry { + if *tests.TestNpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv { InitBuildToolsTests() } if *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan { @@ -85,7 +85,7 @@ func tearDownIntegrationTests() { if (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject { CleanArtifactoryTests() } - if *tests.TestNpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry || *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan { + if *tests.TestNpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan { CleanBuildToolsTests() } if *tests.TestDistribution { diff --git a/poetry_test.go b/poetry_test.go deleted file mode 100644 index 3188ad34d..000000000 --- a/poetry_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package main - -import ( - biutils "github.com/jfrog/build-info-go/utils" - "os" - "path/filepath" - "strconv" - "testing" - - clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" - - buildinfo "github.com/jfrog/build-info-go/entities" - "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" - "github.com/jfrog/jfrog-cli/inttestutils" - "github.com/jfrog/jfrog-cli/utils/tests" - "github.com/jfrog/jfrog-client-go/utils/io/fileutils" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestPoetryInstall(t *testing.T) { - // Init poetry test. - initPoetryTest(t) - tests.SkipKnownFailingTest(t) - // Populate cli config with 'default' server. - oldHomeDir, newHomeDir := prepareHomeDir(t) - defer func() { - assert.NoError(t, os.Setenv(coreutils.HomeDir, oldHomeDir)) - assert.NoError(t, fileutils.RemoveTempDir(newHomeDir)) - }() - - // Create test cases. - allTests := []struct { - name string - project string - outputFolder string - moduleId string - args []string - cleanAfterExecution bool - }{ - {"poetry", "poetryproject", "cli-poetry-build", "cli-poetry-build:0.1.0", []string{"poetry", "install", "--build-name=" + tests.PoetryBuildName}, true}, - } - - // Run test cases. - for buildNumber, test := range allTests { - t.Run(test.name, func(t *testing.T) { - testPoetryCmd(t, createPoetryProject(t, test.outputFolder, test.project), strconv.Itoa(buildNumber), test.moduleId, test.args) - if test.cleanAfterExecution { - // cleanup - inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.PoetryBuildName, artHttpDetails) - } - }) - } - tests.CleanFileSystem() -} - -func testPoetryCmd(t *testing.T, projectPath, buildNumber, module string, args []string) { - wd, err := os.Getwd() - assert.NoError(t, err, "Failed to get current dir") - chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, projectPath) - defer chdirCallback() - - args = append(args, "--build-number="+buildNumber) - - jfrogCli := tests.NewJfrogCli(execMain, "jf", "") - err = jfrogCli.WithoutCredentials().Exec(args...) - if err != nil { - assert.Fail(t, "Failed executing poetry install command", err.Error()) - return - } - - inttestutils.ValidateGeneratedBuildInfoModule(t, tests.PoetryBuildName, buildNumber, "", []string{module}, buildinfo.Python) - assert.NoError(t, artifactoryCli.Exec("bp", tests.PoetryBuildName, buildNumber)) - - publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, tests.PoetryBuildName, buildNumber) - if err != nil { - assert.NoError(t, err) - return - } - if !found { - assert.True(t, found, "build info was expected to be found") - return - } - - buildInfo := publishedBuildInfo.BuildInfo - require.NotEmpty(t, buildInfo.Modules, "Poetry build info was not generated correctly, no modules were created.") - assert.Len(t, buildInfo.Modules[0].Dependencies, 3, "Incorrect number of artifacts found in the build-info") - assert.Equal(t, module, buildInfo.Modules[0].Id, "Unexpected module name") - assertPoetryDependenciesRequestedBy(t, buildInfo.Modules[0], module) -} - -func assertPoetryDependenciesRequestedBy(t *testing.T, module buildinfo.Module, moduleName string) { - for _, dependency := range module.Dependencies { - switch dependency.Id { - case "toml:0.10.2", "pexpect:4.8.0": - assert.EqualValues(t, [][]string{{moduleName}}, dependency.RequestedBy) - case "ptyprocess:0.7.0": - assert.EqualValues(t, [][]string{{"pexpect:4.8.0", moduleName}}, dependency.RequestedBy) - default: - assert.Fail(t, "Unexpected dependency "+dependency.Id) - } - } -} - -func createPoetryProject(t *testing.T, outFolder, projectName string) string { - projectSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "poetry", projectName) - projectTarget := filepath.Join(tests.Out, outFolder+"-poetry-"+projectName) - err := fileutils.CreateDirIfNotExist(projectTarget) - assert.NoError(t, err) - - // Copy poetry project - err = biutils.CopyDir(projectSrc, projectTarget, true, nil) - assert.NoError(t, err) - - // Copy poetry-config file. - configSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "poetry", "poetry.yaml") - configTarget := filepath.Join(projectTarget, ".jfrog", "projects") - _, err = tests.ReplaceTemplateVariables(configSrc, configTarget) - assert.NoError(t, err) - return projectTarget -} - -func initPoetryTest(t *testing.T) { - if !*tests.TestPoetry { - t.Skip("Skipping Poetry test. To run Poetry test add the '-test.poetry=true' option.") - } - require.True(t, isRepoExist(tests.PoetryRemoteRepo), tests.PoetryRemoteRepo+" test repository doesn't exist.") - require.True(t, isRepoExist(tests.PoetryVirtualRepo), tests.PoetryVirtualRepo+" test repository doesn't exist.") -} diff --git a/utils/tests/consts.go b/utils/tests/consts.go index b6e99dc77..abba33009 100644 --- a/utils/tests/consts.go +++ b/utils/tests/consts.go @@ -176,8 +176,6 @@ var ( PypiVirtualRepo = "cli-pypi-virtual" PipenvRemoteRepo = "cli-pipenv-pypi-remote" PipenvVirtualRepo = "cli-pipenv-pypi-virtual" - PoetryRemoteRepo = "cli-poetry-pypi-remote" - PoetryVirtualRepo = "cli-poetry-pypi-virtual" DockerLocalRepo = "cli-docker-local" DockerLocalPromoteRepo = "cli-docker-local-promote" DockerRemoteRepo = "cli-docker-remote" diff --git a/utils/tests/utils.go b/utils/tests/utils.go index 19540b144..b57b42c85 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -65,7 +65,6 @@ var ( TestNuget *bool TestPip *bool TestPipenv *bool - TestPoetry *bool TestPlugins *bool TestXray *bool TestAccess *bool @@ -101,7 +100,6 @@ func init() { TestNuget = flag.Bool("test.nuget", false, "Test Nuget") TestPip = flag.Bool("test.pip", false, "Test Pip") TestPipenv = flag.Bool("test.pipenv", false, "Test Pipenv") - TestPoetry = flag.Bool("test.poetry", false, "Test Poetry") TestPlugins = flag.Bool("test.plugins", false, "Test Plugins") TestXray = flag.Bool("test.xray", false, "Test Xray") TestAccess = flag.Bool("test.access", false, "Test Access") @@ -341,8 +339,6 @@ var reposConfigMap = map[*string]string{ &PypiVirtualRepo: PypiVirtualRepositoryConfig, &PipenvRemoteRepo: PipenvRemoteRepositoryConfig, &PipenvVirtualRepo: PipenvVirtualRepositoryConfig, - &PoetryRemoteRepo: PoetryRemoteRepositoryConfig, - &PoetryVirtualRepo: PoetryVirtualRepositoryConfig, &RtDebianRepo: DebianTestRepositoryConfig, &RtLfsRepo: GitLfsTestRepositoryConfig, &RtRepo1: Repo1RepositoryConfig, @@ -400,7 +396,6 @@ func GetNonVirtualRepositories() map[*string]string { TestNuget: {&NugetRemoteRepo}, TestPip: {&PypiRemoteRepo}, TestPipenv: {&PipenvRemoteRepo}, - TestPoetry: {&PoetryRemoteRepo}, TestPlugins: {&RtRepo1}, TestXray: {}, TestAccess: {&RtRepo1}, @@ -425,7 +420,6 @@ func GetVirtualRepositories() map[*string]string { TestNuget: {}, TestPip: {&PypiVirtualRepo}, TestPipenv: {&PipenvVirtualRepo}, - TestPoetry: {&PoetryVirtualRepo}, TestPlugins: {}, TestXray: {}, TestAccess: {}, @@ -461,7 +455,6 @@ func GetBuildNames() []string { TestNuget: {&NuGetBuildName}, TestPip: {&PipBuildName}, TestPipenv: {&PipenvBuildName}, - TestPoetry: {&PoetryBuildName}, TestPlugins: {}, TestXray: {}, TestAccess: {}, @@ -509,8 +502,6 @@ func getSubstitutionMap() map[string]string { "${PYPI_VIRTUAL_REPO}": PypiVirtualRepo, "${PIPENV_REMOTE_REPO}": PipenvRemoteRepo, "${PIPENV_VIRTUAL_REPO}": PipenvVirtualRepo, - "${POETRY_REMOTE_REPO}": PoetryRemoteRepo, - "${POETRY_VIRTUAL_REPO}": PoetryVirtualRepo, "${BUILD_NAME1}": RtBuildName1, "${BUILD_NAME2}": RtBuildName2, "${BUNDLE_NAME}": BundleName, @@ -567,8 +558,6 @@ func AddTimestampToGlobalVars() { PypiVirtualRepo += uniqueSuffix PipenvRemoteRepo += uniqueSuffix PipenvVirtualRepo += uniqueSuffix - PoetryRemoteRepo += uniqueSuffix - PoetryVirtualRepo += uniqueSuffix RtDebianRepo += uniqueSuffix RtLfsRepo += uniqueSuffix RtRepo1 += uniqueSuffix