Skip to content

Commit 83a2e11

Browse files
authored
Adapt plugins tests following - bug fix - User prompts in plugins are… (#908)
* Adapt plugins tests following - bug fix - User prompts in plugins are invisible * Use jfrog-cli's source code in the plugins tests * Tests fixes * Tests fixes * Bintray tests fixes * Bintray tests fixes * CR fix
1 parent e21f97e commit 83a2e11

File tree

5 files changed

+120
-103
lines changed

5 files changed

+120
-103
lines changed

Diff for: artifactory_test.go

+34-34
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ func TestArtifactoryCopyExcludeByCli(t *testing.T) {
625625
artifactoryCli.Exec("upload", "--spec="+specFileB)
626626

627627
// Copy by pattern
628-
artifactoryCli.Exec("cp", tests.RtRepo1+"/data/ "+tests.RtRepo2+"/", "--exclude-patterns=*b*;*c*")
628+
artifactoryCli.Exec("cp", tests.RtRepo1+"/data/", tests.RtRepo2+"/", "--exclude-patterns=*b*;*c*")
629629

630630
// Validate files are moved by build number
631631
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -1480,14 +1480,14 @@ func TestValidateValidSymlink(t *testing.T) {
14801480
assert.NoError(t, err)
14811481

14821482
// Upload symlink to artifactory
1483-
artifactoryCli.Exec("u", validLink+" "+tests.RtRepo1+" --symlinks=true")
1483+
artifactoryCli.Exec("u", validLink, tests.RtRepo1, "--symlinks=true")
14841484

14851485
// Delete the local symlink
14861486
err = os.Remove(validLink)
14871487
assert.NoError(t, err)
14881488

14891489
// Download symlink from artifactory
1490-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/ --validate-symlinks=true")
1490+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/", "--validate-symlinks=true")
14911491

14921492
// Should be valid if successful
14931493
validateSymLink(validLink, localFile, t)
@@ -1569,10 +1569,10 @@ func TestSymlinkWildcardPathHandling(t *testing.T) {
15691569
err := os.Symlink(localFile, link)
15701570
assert.NoError(t, err)
15711571
link1 := filepath.Join(tests.GetTestResourcesPath()+"a/", "link*")
1572-
artifactoryCli.Exec("u", link1+" "+tests.RtRepo1+" --symlinks=true")
1572+
artifactoryCli.Exec("u", link1, tests.RtRepo1, "--symlinks=true")
15731573
err = os.Remove(link)
15741574
assert.NoError(t, err)
1575-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/ --validate-symlinks=true")
1575+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/", "--validate-symlinks=true")
15761576
validateSymLink(link, localFile, t)
15771577
os.Remove(link)
15781578
cleanArtifactoryTest()
@@ -1589,10 +1589,10 @@ func TestSymlinkToDirHandling(t *testing.T) {
15891589
link := filepath.Join(tests.GetTestResourcesPath()+"a/", "link")
15901590
err := os.Symlink(localFile, link)
15911591
assert.NoError(t, err)
1592-
artifactoryCli.Exec("u", link+" "+tests.RtRepo1+" --symlinks=true --recursive=true")
1592+
artifactoryCli.Exec("u", link, tests.RtRepo1, "--symlinks=true", "--recursive=true")
15931593
err = os.Remove(link)
15941594
assert.NoError(t, err)
1595-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/")
1595+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/")
15961596
validateSymLink(link, localFile, t)
15971597
os.Remove(link)
15981598
cleanArtifactoryTest()
@@ -1610,10 +1610,10 @@ func TestSymlinkToDirWildcardHandling(t *testing.T) {
16101610
err := os.Symlink(localFile, link)
16111611
assert.NoError(t, err)
16121612
link1 := filepath.Join(tests.GetTestResourcesPath()+"a/", "lin*")
1613-
artifactoryCli.Exec("u", link1+" "+tests.RtRepo1+" --symlinks=true --recursive=true")
1613+
artifactoryCli.Exec("u", link1, tests.RtRepo1, "--symlinks=true", "--recursive=true")
16141614
err = os.Remove(link)
16151615
assert.NoError(t, err)
1616-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/")
1616+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/")
16171617
validateSymLink(link, localFile, t)
16181618
os.Remove(link)
16191619
cleanArtifactoryTest()
@@ -1636,14 +1636,14 @@ func TestSymlinkInsideSymlinkDirWithRecursionIssueUpload(t *testing.T) {
16361636
err = os.Symlink(localFilePath, link2)
16371637
assert.NoError(t, err)
16381638

1639-
artifactoryCli.Exec("u", localDirPath+"/link* "+tests.RtRepo1+" --symlinks=true --recursive=true")
1639+
artifactoryCli.Exec("u", localDirPath+"/link*", tests.RtRepo1, "--symlinks=true", "--recursive=true")
16401640
err = os.Remove(link1)
16411641
assert.NoError(t, err)
16421642

16431643
err = os.Remove(link2)
16441644
assert.NoError(t, err)
16451645

1646-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link* "+tests.GetTestResourcesPath()+"a/")
1646+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link*", tests.GetTestResourcesPath()+"a/")
16471647
validateSymLink(link1, localDirPath, t)
16481648
os.Remove(link1)
16491649
validateSymLink(link2, localFilePath, t)
@@ -2245,7 +2245,7 @@ func TestArtifactoryChecksumDownloadRenameFileName(t *testing.T) {
22452245
}
22462246

22472247
func testChecksumDownload(t *testing.T, outFileName string) {
2248-
artifactoryCli.Exec("download "+tests.RtRepo1+"/a1.in", tests.Out+outFileName)
2248+
artifactoryCli.Exec("download", tests.RtRepo1+"/a1.in", tests.Out+outFileName)
22492249

22502250
exists, err := fileutils.IsFileExists(tests.Out+outFileName, false)
22512251
assert.NoError(t, err)
@@ -2254,7 +2254,7 @@ func testChecksumDownload(t *testing.T, outFileName string) {
22542254
firstFileInfo, _ := os.Stat(tests.Out + outFileName)
22552255
firstDownloadTime := firstFileInfo.ModTime()
22562256

2257-
artifactoryCli.Exec("download "+tests.RtRepo1+"/a1.in", tests.Out+outFileName)
2257+
artifactoryCli.Exec("download", tests.RtRepo1+"/a1.in", tests.Out+outFileName)
22582258
secondFileInfo, _ := os.Stat(tests.Out + outFileName)
22592259
secondDownloadTime := secondFileInfo.ModTime()
22602260

@@ -2471,8 +2471,8 @@ func TestArtifactoryDownloadByBuildUsingSimpleDownload(t *testing.T) {
24712471
artifactoryCli.Exec("build-publish", tests.RtBuildName1, buildNumberB)
24722472

24732473
// Download by build number, a1 should not be downloaded, b1 should
2474-
artifactoryCli.Exec("download "+tests.RtRepo1+"/data/a1.in "+filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1)
2475-
artifactoryCli.Exec("download "+tests.RtRepo1+"/data/b1.in "+filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1)
2474+
artifactoryCli.Exec("download", tests.RtRepo1+"/data/a1.in", filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1)
2475+
artifactoryCli.Exec("download", tests.RtRepo1+"/data/b1.in", filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1)
24762476

24772477
// Validate files are downloaded by build number
24782478
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
@@ -2503,7 +2503,7 @@ func TestArtifactoryDownloadByBuildNoPatternUsingSimpleDownload(t *testing.T) {
25032503
artifactoryCli.Exec("build-publish", tests.RtBuildName1, buildNumberB)
25042504

25052505
// Download by build number, a1 should not be downloaded, b1 should
2506-
artifactoryCli.Exec("download * "+filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1+"/"+buildNumberA)
2506+
artifactoryCli.Exec("download", "*", filepath.Join(tests.Out, "download", "simple_by_build")+fileutils.GetFileSeparator(), "--build="+tests.RtBuildName1+"/"+buildNumberA)
25072507

25082508
// Validate files are downloaded by build number
25092509
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
@@ -2611,7 +2611,7 @@ func TestArtifactoryDownloadExcludeByCli(t *testing.T) {
26112611
artifactoryCli.Exec("upload", "--spec="+specFileB, "--recursive=true")
26122612

26132613
// Download by pattern
2614-
artifactoryCli.Exec("download", tests.RtRepo1+" out/download/aql_by_artifacts/", "--exclude-patterns=*/a1.in;*a2.*;data/c2.in")
2614+
artifactoryCli.Exec("download", tests.RtRepo1, "out/download/aql_by_artifacts/", "--exclude-patterns=*/a1.in;*a2.*;data/c2.in")
26152615

26162616
// Validate files are excluded
26172617
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
@@ -2634,7 +2634,7 @@ func TestArtifactoryDownloadExclusionsByCli(t *testing.T) {
26342634
artifactoryCli.Exec("upload", "--spec="+specFileB, "--recursive=true")
26352635

26362636
// Download by pattern
2637-
artifactoryCli.Exec("download", tests.RtRepo1+" out/download/aql_by_artifacts/", "--exclusions=*/*/a1.in;*/*a2.*;*/data/c2.in")
2637+
artifactoryCli.Exec("download", tests.RtRepo1, "out/download/aql_by_artifacts/", "--exclusions=*/*/a1.in;*/*a2.*;*/data/c2.in")
26382638

26392639
// Validate files are excluded
26402640
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
@@ -2759,10 +2759,10 @@ func TestArtifactoryLimitWithSymlink(t *testing.T) {
27592759
link := filepath.Join(tests.GetTestResourcesPath()+"a", "link")
27602760
err := os.Symlink(localFile, link)
27612761
assert.NoError(t, err)
2762-
artifactoryCli.Exec("u", link+" "+tests.RtRepo1+" --symlinks=true")
2762+
artifactoryCli.Exec("u", link, tests.RtRepo1, "--symlinks=true")
27632763
err = os.Remove(link)
27642764
assert.NoError(t, err)
2765-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/ --validate-symlinks=true --limit=1")
2765+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/", "--validate-symlinks=true", "--limit=1")
27662766
validateSortLimitWithSymLink(link, localFile, t)
27672767
os.Remove(link)
27682768
cleanArtifactoryTest()
@@ -2780,10 +2780,10 @@ func TestArtifactorySortWithSymlink(t *testing.T) {
27802780
link := filepath.Join(tests.GetTestResourcesPath()+"a", "link")
27812781
err := os.Symlink(localFile, link)
27822782
assert.NoError(t, err)
2783-
artifactoryCli.Exec("u", link+" "+tests.RtRepo1+" --symlinks=true")
2783+
artifactoryCli.Exec("u", link, tests.RtRepo1, "--symlinks=true")
27842784
err = os.Remove(link)
27852785
assert.NoError(t, err)
2786-
artifactoryCli.Exec("dl", tests.RtRepo1+"/link "+tests.GetTestResourcesPath()+"a/ --validate-symlinks=true --sort-by=created")
2786+
artifactoryCli.Exec("dl", tests.RtRepo1+"/link", tests.GetTestResourcesPath()+"a/", "--validate-symlinks=true", "--sort-by=created")
27872787
validateSortLimitWithSymLink(link, localFile, t)
27882788
os.Remove(link)
27892789
cleanArtifactoryTest()
@@ -2817,7 +2817,7 @@ func TestArtifactoryDownloadByShaAndBuildNameWithSort(t *testing.T) {
28172817
artifactoryCli.Exec("build-publish", tests.RtBuildName2, buildNumberB)
28182818

28192819
// Download by build number
2820-
artifactoryCli.Exec("download", "--sort-by=created --spec="+specFile)
2820+
artifactoryCli.Exec("download", "--sort-by=created", "--spec="+specFile)
28212821

28222822
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(filepath.Join(tests.Out, "download", "sort_limit_by_build"), false)
28232823
err = tests.ValidateListsIdentical(tests.GetBuildDownloadByShaAndBuildNameWithSort(), paths)
@@ -2898,10 +2898,10 @@ func TestArtifactorySortAndLimit(t *testing.T) {
28982898
artifactoryCli.Exec("upload", "testdata/a/(*)", tests.RtRepo1+"/data/{1}")
28992899

29002900
// Download 1 sorted by name asc
2901-
artifactoryCli.Exec("download", tests.RtRepo1+"/data/ out/download/sort_limit/", "--sort-by=name", "--limit=1")
2901+
artifactoryCli.Exec("download", tests.RtRepo1+"/data/", "out/download/sort_limit/", "--sort-by=name", "--limit=1")
29022902

29032903
// Download 3 sorted by depth desc
2904-
artifactoryCli.Exec("download", tests.RtRepo1+"/data/ out/download/sort_limit/", "--sort-by=depth", "--limit=3", "--sort-order=desc")
2904+
artifactoryCli.Exec("download", tests.RtRepo1+"/data/", "out/download/sort_limit/", "--sort-by=depth", "--limit=3", "--sort-order=desc")
29052905

29062906
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
29072907
err := tests.ValidateListsIdentical(tests.GetSortAndLimit(), paths)
@@ -3006,7 +3006,7 @@ func TestArtifactoryCopyByBuildOverridingByInlineFlag(t *testing.T) {
30063006
artifactoryCli.Exec("build-publish", tests.RtBuildName1, buildNumberB)
30073007

30083008
// Copy by build number: using override of build by flag from inline (no number set so LATEST build should be copied), a* should be copied
3009-
artifactoryCli.Exec("copy", "--build="+tests.RtBuildName1+" --spec="+specFile)
3009+
artifactoryCli.Exec("copy", "--build="+tests.RtBuildName1, "--spec="+specFile)
30103010

30113011
// Validate files are Copied by build number
30123012
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -3039,7 +3039,7 @@ func TestArtifactoryMoveByBuildUsingFlags(t *testing.T) {
30393039
artifactoryCli.Exec("build-publish", tests.RtBuildName1, buildNumberB)
30403040

30413041
// Move by build name and number
3042-
artifactoryCli.Exec("move", "--build="+tests.RtBuildName1+"/11 --spec="+specFile)
3042+
artifactoryCli.Exec("move", "--build="+tests.RtBuildName1+"/11", "--spec="+specFile)
30433043

30443044
// Validate files are moved by build number
30453045
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -3068,7 +3068,7 @@ func TestArtifactoryMoveExcludeByCli(t *testing.T) {
30683068
artifactoryCli.Exec("upload", "--spec="+specFileB)
30693069

30703070
// Move by pattern
3071-
artifactoryCli.Exec("move", tests.RtRepo1+"/data/ "+tests.RtRepo2+"/", "--exclude-patterns=*b*;*c*")
3071+
artifactoryCli.Exec("move", tests.RtRepo1+"/data/", tests.RtRepo2+"/", "--exclude-patterns=*b*;*c*")
30723072

30733073
// Validate excluded files didn't move
30743074
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -3092,7 +3092,7 @@ func TestArtifactoryMoveExclusionsByCli(t *testing.T) {
30923092
artifactoryCli.Exec("upload", "--spec="+specFileB)
30933093

30943094
// Move by pattern
3095-
artifactoryCli.Exec("move", tests.RtRepo1+"/data/ "+tests.RtRepo2+"/", "--exclusions=*/*b*;*/*c*")
3095+
artifactoryCli.Exec("move", tests.RtRepo1+"/data/", tests.RtRepo2+"/", "--exclusions=*/*b*;*/*c*")
30963096

30973097
// Validate excluded files didn't move
30983098
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -3176,7 +3176,7 @@ func TestArtifactoryDeleteByLatestBuild(t *testing.T) {
31763176
artifactoryCli.Exec("build-publish", tests.RtBuildName1, buildNumberB)
31773177

31783178
// Delete by build name and LATEST
3179-
artifactoryCli.Exec("delete", "--build="+tests.RtBuildName1+"/LATEST --spec="+specFile)
3179+
artifactoryCli.Exec("delete", "--build="+tests.RtBuildName1+"/LATEST", "--spec="+specFile)
31803180

31813181
// Validate files are deleted by build number
31823182
cpMvDlByBuildAssertSpec, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
@@ -3607,8 +3607,8 @@ func cleanArtifactoryTest() {
36073607
func preUploadBasicTestResources() {
36083608
uploadPath := tests.GetTestResourcesPath() + "a/(.*)"
36093609
targetPath := tests.RtRepo1 + "/test_resources/{1}"
3610-
flags := "--threads=10 --regexp=true --props=searchMe=true --flat=false"
3611-
artifactoryCli.Exec("upload", uploadPath, targetPath, flags)
3610+
artifactoryCli.Exec("upload", uploadPath, targetPath,
3611+
"--threads=10", "--regexp=true", "--props=searchMe=true", "--flat=false")
36123612
}
36133613

36143614
func execDeleteRepo(repoName string) {
@@ -3888,15 +3888,15 @@ func testCopyMoveNoSpec(command string, beforeCommandExpected, afterCommandExpec
38883888
artifactoryCli.Exec("upload", "--spec="+specFileB)
38893889

38903890
// Run command with dry-run
3891-
artifactoryCli.Exec(command, tests.RtRepo1+"/data/*a* "+tests.RtRepo2+"/", "--dry-run")
3891+
artifactoryCli.Exec(command, tests.RtRepo1+"/data/*a*", tests.RtRepo2+"/", "--dry-run")
38923892

38933893
// Validate files weren't affected
38943894
cpMvSpecFilePath, err := tests.CreateSpec(tests.CpMvDlByBuildAssertSpec)
38953895
assert.NoError(t, err)
38963896
verifyExistInArtifactory(beforeCommandExpected, cpMvSpecFilePath, t)
38973897

38983898
// Run command
3899-
artifactoryCli.Exec(command, tests.RtRepo1+"/data/*a* "+tests.RtRepo2+"/")
3899+
artifactoryCli.Exec(command, tests.RtRepo1+"/data/*a*", tests.RtRepo2+"/")
39003900

39013901
// Validate files were affected
39023902
verifyExistInArtifactory(afterCommandExpected, cpMvSpecFilePath, t)

0 commit comments

Comments
 (0)