@@ -12,6 +12,7 @@ import (
1212 "io"
1313 "net/http"
1414 "net/http/httptest"
15+ "strconv"
1516 "testing"
1617 "time"
1718
@@ -109,8 +110,6 @@ func TestPackageNuGet(t *testing.T) {
109110 url := fmt .Sprintf ("/api/packages/%s/nuget" , user .Name )
110111
111112 t .Run ("ServiceIndex" , func (t * testing.T ) {
112- defer tests .PrintCurrentTest (t )()
113-
114113 t .Run ("v2" , func (t * testing.T ) {
115114 defer tests .PrintCurrentTest (t )()
116115
@@ -374,8 +373,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
374373 })
375374
376375 t .Run ("SearchService" , func (t * testing.T ) {
377- defer tests .PrintCurrentTest (t )()
378-
379376 cases := []struct {
380377 Query string
381378 Skip int
@@ -391,8 +388,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
391388 }
392389
393390 t .Run ("v2" , func (t * testing.T ) {
394- defer tests .PrintCurrentTest (t )()
395-
396391 t .Run ("Search()" , func (t * testing.T ) {
397392 defer tests .PrintCurrentTest (t )()
398393
@@ -406,14 +401,20 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
406401
407402 assert .Equal (t , c .ExpectedTotal , result .Count , "case %d: unexpected total hits" , i )
408403 assert .Len (t , result .Entries , c .ExpectedResults , "case %d: unexpected result count" , i )
404+
405+ req = NewRequest (t , "GET" , fmt .Sprintf ("%s/Search()/$count?searchTerm='%s'&skip=%d&take=%d" , url , c .Query , c .Skip , c .Take ))
406+ req = AddBasicAuthHeader (req , user .Name )
407+ resp = MakeRequest (t , req , http .StatusOK )
408+
409+ assert .Equal (t , strconv .FormatInt (c .ExpectedTotal , 10 ), resp .Body .String (), "case %d: unexpected total hits" , i )
409410 }
410411 })
411412
412413 t .Run ("Packages()" , func (t * testing.T ) {
413414 defer tests .PrintCurrentTest (t )()
414415
415416 for i , c := range cases {
416- req := NewRequest (t , "GET" , fmt .Sprintf ("%s/Search ()?$filter=substringof('%s',tolower(Id))&$skip=%d&$top=%d" , url , c .Query , c .Skip , c .Take ))
417+ req := NewRequest (t , "GET" , fmt .Sprintf ("%s/Packages ()?$filter=substringof('%s',tolower(Id))&$skip=%d&$top=%d" , url , c .Query , c .Skip , c .Take ))
417418 req = AddBasicAuthHeader (req , user .Name )
418419 resp := MakeRequest (t , req , http .StatusOK )
419420
@@ -422,6 +423,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
422423
423424 assert .Equal (t , c .ExpectedTotal , result .Count , "case %d: unexpected total hits" , i )
424425 assert .Len (t , result .Entries , c .ExpectedResults , "case %d: unexpected result count" , i )
426+
427+ 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 ))
428+ req = AddBasicAuthHeader (req , user .Name )
429+ resp = MakeRequest (t , req , http .StatusOK )
430+
431+ assert .Equal (t , strconv .FormatInt (c .ExpectedTotal , 10 ), resp .Body .String (), "case %d: unexpected total hits" , i )
425432 }
426433 })
427434 })
@@ -512,8 +519,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
512519 })
513520
514521 t .Run ("RegistrationLeaf" , func (t * testing.T ) {
515- defer tests .PrintCurrentTest (t )()
516-
517522 t .Run ("v2" , func (t * testing.T ) {
518523 defer tests .PrintCurrentTest (t )()
519524
@@ -549,8 +554,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
549554 })
550555
551556 t .Run ("PackageService" , func (t * testing.T ) {
552- defer tests .PrintCurrentTest (t )()
553-
554557 t .Run ("v2" , func (t * testing.T ) {
555558 defer tests .PrintCurrentTest (t )()
556559
@@ -563,6 +566,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
563566
564567 assert .Len (t , result .Entries , 1 )
565568 assert .Equal (t , packageVersion , result .Entries [0 ].Properties .Version )
569+
570+ req = NewRequest (t , "GET" , fmt .Sprintf ("%s/FindPackagesById()/$count?id='%s'" , url , packageName ))
571+ req = AddBasicAuthHeader (req , user .Name )
572+ resp = MakeRequest (t , req , http .StatusOK )
573+
574+ assert .Equal (t , "1" , resp .Body .String ())
566575 })
567576
568577 t .Run ("v3" , func (t * testing.T ) {
0 commit comments