-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from 030/194-regex-env-variables
[#194] Allow overwrite of regex to ensure that various artifact types…
- Loading branch information
Showing
7 changed files
with
103 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
package artifacts | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestArtifactTypeDetectorErrors(t *testing.T) { | ||
var sb strings.Builder | ||
|
||
os.Setenv("N3DR_MAVEN_UPLOAD_REGEX_VERSION", "notAMatch") | ||
err := artifactTypeDetector(&sb, "a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar", false) | ||
assert.EqualError(t, err, "Check whether regexVersion: 'notAMatch' and regexClassifier: '([a-zA-Z]+)?' match the artifact: 'a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar'") | ||
|
||
os.Setenv("N3DR_MAVEN_UPLOAD_REGEX_CLASSIFIER", "notAMatch2") | ||
err = artifactTypeDetector(&sb, "a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar", false) | ||
assert.EqualError(t, err, "Check whether regexVersion: 'notAMatch' and regexClassifier: 'notAMatch2' match the artifact: 'a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar'") | ||
} | ||
|
||
func TestArtifactTypeDetector(t *testing.T) { | ||
var sb strings.Builder | ||
|
||
artifactTypeDetector(&sb, "a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar") | ||
artifactTypeDetector(&sb, "d/e/f-e-d/4.5.6/d.e.f-4.5.6.pom") | ||
artifactTypeDetector(&sb, "d/e/f-e-d/7.8.9-2-37zgb398/d.e.f-7.8.9-2-37zgb398.war") | ||
artifactTypeDetector(&sb, "d/e/f-e-d/9.8.7-81ae5835bb36126fe8091e82t14521841d8y0133/d.e.f-9.8.7-81ae5835bb36126fe8091e82t14521841d8y0133.war") | ||
os.Setenv("N3DR_MAVEN_UPLOAD_REGEX_VERSION", `([\d\.-]+\d)`) | ||
os.Setenv("N3DR_MAVEN_UPLOAD_REGEX_CLASSIFIER", `([a-zA-Z]+)?`) | ||
|
||
artifactTypeDetector(&sb, "a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar", false) | ||
artifactTypeDetector(&sb, "d/e/f-e-d/4.5.6/d.e.f-4.5.6.pom", false) | ||
artifactTypeDetector(&sb, "d/e/f-e-d/7.8.9-2/d.e.f-7.8.9-2.war", false) | ||
|
||
assert.Equal(t, "maven2.asset0=@a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar,maven2.asset0.extension=jar,maven2.asset0.classifier=dataset,maven2.asset1=@d/e/f-e-d/4.5.6/d.e.f-4.5.6.pom,maven2.asset1.extension=pom,maven2.asset2=@d/e/f-e-d/7.8.9-2-37zgb398/d.e.f-7.8.9-2-37zgb398.war,maven2.asset2.extension=war,maven2.asset3=@d/e/f-e-d/9.8.7-81ae5835bb36126fe8091e82t14521841d8y0133/d.e.f-9.8.7-81ae5835bb36126fe8091e82t14521841d8y0133.war,maven2.asset3.extension=war,", sb.String()) | ||
assert.Equal(t, "maven2.asset0=@a/b/c.b.a/1.2.3/a-b-c-1.2.3-dataset.jar,maven2.asset0.extension=jar,maven2.asset0.classifier=dataset,maven2.asset1=@d/e/f-e-d/4.5.6/d.e.f-4.5.6.pom,maven2.asset1.extension=pom,maven2.asset2=@d/e/f-e-d/7.8.9-2/d.e.f-7.8.9-2.war,maven2.asset2.extension=war,", sb.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters