Skip to content

Commit 6e1bf93

Browse files
authored
Fix dotnet curation tests after Artifactory CLI migration (#309)
1 parent ff84117 commit 6e1bf93

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Diff for: commands/curation/curationaudit_test.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"net/http/httptest"
1010
"os"
1111
"os/exec"
12-
"path"
1312
"path/filepath"
1413
"regexp"
1514
"sort"
@@ -799,9 +798,9 @@ func getTestCasesForDoCurationAudit() []testCase {
799798
tech: techutils.Dotnet,
800799
pathToProject: filepath.Join("projects", "package-managers", "dotnet", "dotnet-curation"),
801800
serveResources: map[string]string{
802-
"curated-nuget": filepath.Join("resources", "feed.json"),
803-
"index.json": filepath.Join("resources", "index.json"),
804-
"13.0.3": filepath.Join("resources", "newtonsoft.json.13.0.3.nupkg"),
801+
"curated-nuget/index.json": filepath.Join("resources", "feed.json"),
802+
"index.json": filepath.Join("resources", "index.json"),
803+
"13.0.3": filepath.Join("resources", "newtonsoft.json.13.0.3.nupkg"),
805804
},
806805
requestToFail: map[string]bool{
807806
"/api/nuget/v3/curated-nuget/registration-semver2/Download/newtonsoft.json/13.0.3": false,
@@ -853,7 +852,7 @@ func curationServer(t *testing.T, expectedBuildRequest map[string]bool, expected
853852
}
854853
if r.Method == http.MethodGet {
855854
if resourceToServe != nil {
856-
if pathToRes, ok := resourceToServe[path.Base(r.RequestURI)]; ok && strings.Contains(r.RequestURI, "api/curation/audit") {
855+
if pathToRes := getResourceToServe(resourceToServe, r.RequestURI); pathToRes != "" && strings.Contains(r.RequestURI, "api/curation/audit") {
857856
f, err := fileutils.ReadFile(pathToRes)
858857
require.NoError(t, err)
859858
f = bytes.ReplaceAll(f, []byte("127.0.0.1:80"), []byte(r.Host))
@@ -880,6 +879,15 @@ func curationServer(t *testing.T, expectedBuildRequest map[string]bool, expected
880879
return serverMock, config
881880
}
882881

882+
func getResourceToServe(resourcesToServe map[string]string, pathToRes string) string {
883+
for key, value := range resourcesToServe {
884+
if strings.HasSuffix(strings.TrimSuffix(pathToRes, "/"), key) {
885+
return value
886+
}
887+
}
888+
return ""
889+
}
890+
883891
func WriteServerDetailsConfigFileBytes(t *testing.T, url string, configPath string, withoutCreds bool) string {
884892
var username, password string
885893
if !withoutCreds {

Diff for: go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ require (
113113

114114
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go dev
115115

116-
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250128111343-44586261061e
116+
// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 dev
117117

118-
replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.1.12-0.20250128042424-bb6a289e237c
118+
// replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory main
119119

120120
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev
121121

Diff for: go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
128128
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
129129
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
130130
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
131-
github.com/jfrog/jfrog-cli-artifactory v0.1.12-0.20250128042424-bb6a289e237c h1:9975QDk6vBZG7vjsKVCuQB56r4xxeoYHHjmTzxbd4H8=
132-
github.com/jfrog/jfrog-cli-artifactory v0.1.12-0.20250128042424-bb6a289e237c/go.mod h1:/sP5tyuFpH9WJp0+vztczuXcxIYHlMye0CDWCxhy4/M=
133-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250128111343-44586261061e h1:QieRnuB+YDGS8c5QIt5bcJblE8KnomnHn3fpP9bymI8=
134-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250128111343-44586261061e/go.mod h1:ALempEeph7JoZZS2ob7xK+0r9v82z8IBDzQB1hnaxuQ=
131+
github.com/jfrog/jfrog-cli-artifactory v0.1.12 h1:Nj6D1605/rr097LVQGZjJL4xOFEdATu6O+PIyg/f9T0=
132+
github.com/jfrog/jfrog-cli-artifactory v0.1.12/go.mod h1:7wqnff7YstYHJbe/T3lKj+fJ5GxImlTjJp8nSZGcYm4=
133+
github.com/jfrog/jfrog-cli-core/v2 v2.58.0 h1:tPjwJdWNv9PTz1ma5TjrMd9Uu0btcQg8eBCpc5h/rn4=
134+
github.com/jfrog/jfrog-cli-core/v2 v2.58.0/go.mod h1:Hx2houXADsNv0eRh4w5XCS2uSsPNPn1OmiSDdwGFB7g=
135135
github.com/jfrog/jfrog-client-go v1.50.0 h1:t7v/zpLkPomHR6ZjVbPQ1WPQJd9IFKESK9Tt6phZz3k=
136136
github.com/jfrog/jfrog-client-go v1.50.0/go.mod h1:xHxwKBjPSUBd/FyCWgusfHmSWKUZTkfOZkTmntC2F5Y=
137137
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=

0 commit comments

Comments
 (0)