diff options
author | KN4CK3R | 2023-02-11 12:30:44 +0100 |
---|---|---|
committer | GitHub | 2023-02-11 19:30:44 +0800 |
commit | 9057a008a1019144611aa9e3fd53a5e3a404c389 (patch) | |
tree | d4a3dd87ec8dfb6c734d5f846fa2f816a33a26b9 /tests | |
parent | fb1a2a13f05665764a6f91ed1a421b9e93c4e8c9 (diff) |
Add `/$count` endpoints for NuGet v2 (#22855)
Fixes #22838
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_packages_nuget_test.go | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/tests/integration/api_packages_nuget_test.go b/tests/integration/api_packages_nuget_test.go index cc4ff180d..a74d696f0 100644 --- a/tests/integration/api_packages_nuget_test.go +++ b/tests/integration/api_packages_nuget_test.go @@ -12,6 +12,7 @@ import ( "io" "net/http" "net/http/httptest" + "strconv" "testing" "time" @@ -109,8 +110,6 @@ func TestPackageNuGet(t *testing.T) { url := fmt.Sprintf("/api/packages/%s/nuget", user.Name) t.Run("ServiceIndex", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - t.Run("v2", func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -374,8 +373,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) }) t.Run("SearchService", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - cases := []struct { Query string Skip int @@ -391,8 +388,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) } t.Run("v2", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - t.Run("Search()", func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -406,6 +401,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) assert.Equal(t, c.ExpectedTotal, result.Count, "case %d: unexpected total hits", i) assert.Len(t, result.Entries, c.ExpectedResults, "case %d: unexpected result count", i) + + req = NewRequest(t, "GET", fmt.Sprintf("%s/Search()/$count?searchTerm='%s'&skip=%d&take=%d", url, c.Query, c.Skip, c.Take)) + req = AddBasicAuthHeader(req, user.Name) + resp = MakeRequest(t, req, http.StatusOK) + + assert.Equal(t, strconv.FormatInt(c.ExpectedTotal, 10), resp.Body.String(), "case %d: unexpected total hits", i) } }) @@ -413,7 +414,7 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) defer tests.PrintCurrentTest(t)() for i, c := range cases { - req := NewRequest(t, "GET", fmt.Sprintf("%s/Search()?$filter=substringof('%s',tolower(Id))&$skip=%d&$top=%d", url, c.Query, c.Skip, c.Take)) + req := NewRequest(t, "GET", fmt.Sprintf("%s/Packages()?$filter=substringof('%s',tolower(Id))&$skip=%d&$top=%d", url, c.Query, c.Skip, c.Take)) req = AddBasicAuthHeader(req, user.Name) resp := MakeRequest(t, req, http.StatusOK) @@ -422,6 +423,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) assert.Equal(t, c.ExpectedTotal, result.Count, "case %d: unexpected total hits", i) assert.Len(t, result.Entries, c.ExpectedResults, "case %d: unexpected result count", i) + + req = NewRequest(t, "GET", fmt.Sprintf("%s/Packages()/$count?$filter=substringof('%s',tolower(Id))&$skip=%d&$top=%d", url, c.Query, c.Skip, c.Take)) + req = AddBasicAuthHeader(req, user.Name) + resp = MakeRequest(t, req, http.StatusOK) + + assert.Equal(t, strconv.FormatInt(c.ExpectedTotal, 10), resp.Body.String(), "case %d: unexpected total hits", i) } }) }) @@ -512,8 +519,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) }) t.Run("RegistrationLeaf", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - t.Run("v2", func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -549,8 +554,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) }) t.Run("PackageService", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - t.Run("v2", func(t *testing.T) { defer tests.PrintCurrentTest(t)() @@ -563,6 +566,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) assert.Len(t, result.Entries, 1) assert.Equal(t, packageVersion, result.Entries[0].Properties.Version) + + req = NewRequest(t, "GET", fmt.Sprintf("%s/FindPackagesById()/$count?id='%s'", url, packageName)) + req = AddBasicAuthHeader(req, user.Name) + resp = MakeRequest(t, req, http.StatusOK) + + assert.Equal(t, "1", resp.Body.String()) }) t.Run("v3", func(t *testing.T) { |