@@ -12,6 +12,7 @@ import (
12
12
"io"
13
13
"net/http"
14
14
"net/http/httptest"
15
+ "strconv"
15
16
"testing"
16
17
"time"
17
18
@@ -109,8 +110,6 @@ func TestPackageNuGet(t *testing.T) {
109
110
url := fmt .Sprintf ("/api/packages/%s/nuget" , user .Name )
110
111
111
112
t .Run ("ServiceIndex" , func (t * testing.T ) {
112
- defer tests .PrintCurrentTest (t )()
113
-
114
113
t .Run ("v2" , func (t * testing.T ) {
115
114
defer tests .PrintCurrentTest (t )()
116
115
@@ -374,8 +373,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
374
373
})
375
374
376
375
t .Run ("SearchService" , func (t * testing.T ) {
377
- defer tests .PrintCurrentTest (t )()
378
-
379
376
cases := []struct {
380
377
Query string
381
378
Skip int
@@ -391,8 +388,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
391
388
}
392
389
393
390
t .Run ("v2" , func (t * testing.T ) {
394
- defer tests .PrintCurrentTest (t )()
395
-
396
391
t .Run ("Search()" , func (t * testing.T ) {
397
392
defer tests .PrintCurrentTest (t )()
398
393
@@ -406,14 +401,20 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
406
401
407
402
assert .Equal (t , c .ExpectedTotal , result .Count , "case %d: unexpected total hits" , i )
408
403
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 )
409
410
}
410
411
})
411
412
412
413
t .Run ("Packages()" , func (t * testing.T ) {
413
414
defer tests .PrintCurrentTest (t )()
414
415
415
416
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 ))
417
418
req = AddBasicAuthHeader (req , user .Name )
418
419
resp := MakeRequest (t , req , http .StatusOK )
419
420
@@ -422,6 +423,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
422
423
423
424
assert .Equal (t , c .ExpectedTotal , result .Count , "case %d: unexpected total hits" , i )
424
425
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 )
425
432
}
426
433
})
427
434
})
@@ -512,8 +519,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
512
519
})
513
520
514
521
t .Run ("RegistrationLeaf" , func (t * testing.T ) {
515
- defer tests .PrintCurrentTest (t )()
516
-
517
522
t .Run ("v2" , func (t * testing.T ) {
518
523
defer tests .PrintCurrentTest (t )()
519
524
@@ -549,8 +554,6 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
549
554
})
550
555
551
556
t .Run ("PackageService" , func (t * testing.T ) {
552
- defer tests .PrintCurrentTest (t )()
553
-
554
557
t .Run ("v2" , func (t * testing.T ) {
555
558
defer tests .PrintCurrentTest (t )()
556
559
@@ -563,6 +566,12 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`)
563
566
564
567
assert .Len (t , result .Entries , 1 )
565
568
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 ())
566
575
})
567
576
568
577
t .Run ("v3" , func (t * testing.T ) {
0 commit comments