Skip to content

Commit

Permalink
Added test case for --build-name with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
agrasthn authored and agrasthn committed Jan 29, 2025
1 parent 8800f64 commit 1640954
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions utils/tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1640954

Please sign in to comment.