From 1640954cad81b4bedb247077d9ec7b966746626a Mon Sep 17 00:00:00 2001 From: agrasthn Date: Wed, 29 Jan 2025 10:29:45 +0530 Subject: [PATCH] Added test case for --build-name with spaces --- artifactory_test.go | 33 +++++++++++++++++++++++++++++++++ utils/tests/consts.go | 1 + 2 files changed, 34 insertions(+) diff --git a/artifactory_test.go b/artifactory_test.go index 61f13fb2f..743ba99c4 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -3267,6 +3267,39 @@ func TestArtifactoryDownloadByShaAndBuild(t *testing.T) { cleanArtifactoryTest() } +func TestArtifactoryUploadWithBuildNameWithSpaces(t *testing.T) { + initArtifactoryTest(t, "") + + buildNumber := "1" + + // Delete the build if it already exists + inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.RtBuildNameWithSpaces, artHttpDetails) + + // Upload a file with build name containing spaces + runRt(t, "upload", "testdata/a/a1.in", tests.RtRepo1+"/data/a1.in", + "--build-name="+tests.RtBuildNameWithSpaces, "--build-number="+buildNumber) + + // Publish build info + runRt(t, "build-publish", tests.RtBuildNameWithSpaces, buildNumber) + + // Validate that the file was uploaded successfully + specFile, err := tests.CreateSpec(tests.BuildDownloadSpecNoBuildNumber) + assert.NoError(t, err) + + runRt(t, "download", "--spec="+specFile) + + // Validate downloaded files + paths, err := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) + assert.NoError(t, err) + err = tests.ValidateListsIdentical(tests.GetBuildDownload(), paths) + assert.NoError(t, err) + + // Cleanup + inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.RtBuildNameWithSpaces, artHttpDetails) + cleanArtifactoryTest() +} + + // Upload a file to 2 different builds. // Verify that we don't download files with same sha and build name and different build number. func TestArtifactoryDownloadByShaAndBuildName(t *testing.T) { diff --git a/utils/tests/consts.go b/utils/tests/consts.go index 2efa5b889..e34eac317 100644 --- a/utils/tests/consts.go +++ b/utils/tests/consts.go @@ -221,6 +221,7 @@ var ( PipenvBuildName = "cli-pipenv-build" RtBuildName1 = "cli-rt-build1" RtBuildName2 = "cli-rt-build2" + RtBuildNameWithSpaces = "cli build with spaces" RtBuildNameWithSpecialChars = "cli-rt-a$+~&^a#-build3" RtPermissionTargetName = "cli-rt-pt" LcBuildName1 = "cli-lc-build1"