Commit f0ee2c5 1 parent a8bdf18 commit f0ee2c5 Copy full SHA for f0ee2c5
File tree 2 files changed +29
-1
lines changed
src/BaGet.Hosting/Controllers
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,14 @@ public async Task<ActionResult<AutocompleteResponse>> AutocompleteAsync(
69
69
}
70
70
71
71
public async Task < ActionResult < DependentsResponse > > DependentsAsync (
72
- [ FromQuery ] string packageId ,
72
+ [ FromQuery ] string packageId = null ,
73
73
CancellationToken cancellationToken = default )
74
74
{
75
+ if ( string . IsNullOrWhiteSpace ( packageId ) )
76
+ {
77
+ return BadRequest ( ) ;
78
+ }
79
+
75
80
return await _searchService . FindDependentsAsync ( packageId , cancellationToken ) ;
76
81
}
77
82
}
Original file line number Diff line number Diff line change @@ -290,6 +290,29 @@ public async Task PackageMetadataLeafReturnsNotFound()
290
290
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
291
291
}
292
292
293
+ [ Fact ]
294
+ public async Task PackageDependentsReturnsOk ( )
295
+ {
296
+ using var response = await _client . GetAsync ( "v3/dependents?packageId=DefaultPackage" ) ;
297
+
298
+ var content = await response . Content . ReadAsStreamAsync ( ) ;
299
+ var json = PrettifyJson ( content ) ;
300
+
301
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
302
+ Assert . Equal ( @"{
303
+ ""totalHits"": 0,
304
+ ""data"": []
305
+ }" , json ) ;
306
+ }
307
+
308
+ [ Fact ]
309
+ public async Task PackageDependentsReturnsBadRequest ( )
310
+ {
311
+ using var response = await _client . GetAsync ( "v3/dependents" ) ;
312
+
313
+ Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
314
+ }
315
+
293
316
private string PrettifyJson ( Stream jsonStream )
294
317
{
295
318
using var writer = new StringWriter ( ) ;
You can’t perform that action at this time.
0 commit comments