Skip to content

Commit

Permalink
Merge pull request #76 from treatwell/incorrect-artifact-name
Browse files Browse the repository at this point in the history
Incorrect artifact name when path contains repository name
  • Loading branch information
030 authored Aug 5, 2019
2 parents 41b71de + 5d154f6 commit 1c948ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ env:
- GO111MODULE=on
matrix:
include:
- os: linux
dist: bionic
env:
- ARTIFACT_PUBLICATION=false
- NEXUS_VERSION=latest
- NEXUS_API_VERSION=v1
- os: linux
dist: bionic
env:
Expand Down
2 changes: 1 addition & 1 deletion cli/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (n Nexus3) artifactName(url string) (string, string, error) {
return "", "", errors.New(url + " is not an URL")
}

re := regexp.MustCompile("^.*/" + n.Repository + "/(.*)/(.+)$")
re := regexp.MustCompile("^.*?/" + n.Repository + "/(.*)/(.+)$")
match := re.FindStringSubmatch(url)
if match == nil {
return "", "", errors.New("URL: '" + url + "' does not seem to contain an artifactName")
Expand Down
17 changes: 17 additions & 0 deletions cli/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ func TestArtifactName(t *testing.T) {
}
}

func TestArtifactNameContainingRepositoryName(t *testing.T) {
actualDir, actualFile, _ := n.artifactName("http://localhost:9999/repository/maven-releases/com/maven-releases/tools/1.0.0/tools-1.0.0.jar")
expectedDir := "com/maven-releases/tools/1.0.0"
expectedFile := "tools-1.0.0.jar"

if expectedDir != actualDir || expectedFile != actualFile {
t.Errorf("Dir and file incorrect. Expected: %v & %v. Actual: %v & %v", expectedDir, expectedFile, actualDir, actualFile)
}

_, _, actualError := n.artifactName("some-url")
expectedError := "some-url is not an URL"

if actualError.Error() != expectedError {
t.Errorf(errMsgTxt, expectedError, actualError)
}
}

func TestCreateArtifact(t *testing.T) {
actualErrorFile := createArtifact("testFiles", "file100/file100", "some-content")
expectedErrorFile := "open testFiles/file100/file100: no such file or directory"
Expand Down

0 comments on commit 1c948ce

Please sign in to comment.