Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
asafambar committed Feb 14, 2024
1 parent 8db46ac commit ac72344
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions commands/curation/curationaudit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,75 @@ func WriteServerDetailsConfigFileBytes(t *testing.T, url string, configPath stri
assert.NoError(t, os.WriteFile(confFilePath, detailsByte, 0644))
return confFilePath
}

func Test_getMavenNameScopeAndVersion(t *testing.T) {
type args struct {
id string
artiUrl string
repo string
types *[]string
}
tests := []struct {
name string
args args
wantDownloadUrls []string
wantName string
wantScope string
wantVersion string
}{
{
name: "maven url jar",
args: args{
id: "gav://org.apache.tomcat.embed:tomcat-embed-jasper:8.0.33",
artiUrl: "http://test:9000/artifactory",
repo: "maven-remote",
types: &[]string{"jar"},
},
wantDownloadUrls: []string{"http://test:9000/artifactory/maven-remote/org/apache/tomcat/embed/tomcat-embed-jasper/8.0.33/tomcat-embed-jasper-8.0.33.jar"},
wantName: "org.apache.tomcat.embed:tomcat-embed-jasper",
wantVersion: "8.0.33",
},
{
name: "maven url jar and war",
args: args{
id: "gav://org.apache.tomcat.embed:tomcat-embed-jasper:8.0.33",
artiUrl: "http://test:9000/artifactory",
repo: "maven-remote",
types: &[]string{"jar", "war"},
},
wantDownloadUrls: []string{"http://test:9000/artifactory/maven-remote/org/apache/tomcat/embed/tomcat-embed-jasper/8.0.33/tomcat-embed-jasper-8.0.33.jar",
"http://test:9000/artifactory/maven-remote/org/apache/tomcat/embed/tomcat-embed-jasper/8.0.33/tomcat-embed-jasper-8.0.33.war"},
wantName: "org.apache.tomcat.embed:tomcat-embed-jasper",
wantVersion: "8.0.33",
},
{
name: "maven url pom - no expected url",
args: args{
id: "gav://org.apache.tomcat.embed:tomcat-embed-jasper:8.0.33",
artiUrl: "http://test:9000/artifactory",
repo: "maven-remote",
types: &[]string{"pom"},
},
wantName: "org.apache.tomcat.embed:tomcat-embed-jasper",
wantVersion: "8.0.33",
},
{
name: "bad id",
args: args{
id: "gav://org.apache.tomcat.embed:8.0.33",
artiUrl: "http://test:9000/artifactory",
repo: "maven-remote",
types: &[]string{"jar"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotDownloadUrls, gotName, gotScope, gotVersion := getMavenNameScopeAndVersion(tt.args.id, tt.args.artiUrl, tt.args.repo, tt.args.types)
assert.Equalf(t, tt.wantDownloadUrls, gotDownloadUrls, "getMavenNameScopeAndVersion(%v, %v, %v, %v)", tt.args.id, tt.args.artiUrl, tt.args.repo, tt.args.types)
assert.Equalf(t, tt.wantName, gotName, "getMavenNameScopeAndVersion(%v, %v, %v, %v)", tt.args.id, tt.args.artiUrl, tt.args.repo, tt.args.types)
assert.Equalf(t, tt.wantScope, gotScope, "getMavenNameScopeAndVersion(%v, %v, %v, %v)", tt.args.id, tt.args.artiUrl, tt.args.repo, tt.args.types)
assert.Equalf(t, tt.wantVersion, gotVersion, "getMavenNameScopeAndVersion(%v, %v, %v, %v)", tt.args.id, tt.args.artiUrl, tt.args.repo, tt.args.types)
})
}
}

0 comments on commit ac72344

Please sign in to comment.