@@ -18,9 +18,7 @@ use crate::{
18
18
} ;
19
19
use anyhow:: { Result , anyhow} ;
20
20
use askama:: Template ;
21
- use axum:: {
22
- Json , extract:: Extension , http:: header:: ACCESS_CONTROL_ALLOW_ORIGIN , response:: IntoResponse ,
23
- } ;
21
+ use axum:: { Json , extract:: Extension , response:: IntoResponse } ;
24
22
use axum_extra:: {
25
23
TypedHeader ,
26
24
headers:: { Authorization , authorization:: Bearer } ,
@@ -84,53 +82,6 @@ pub(crate) async fn build_list_handler(
84
82
. into_response ( ) )
85
83
}
86
84
87
- pub ( crate ) async fn build_list_json_handler (
88
- Path ( ( name, req_version) ) : Path < ( String , ReqVersion ) > ,
89
- mut conn : DbConnection ,
90
- ) -> AxumResult < impl IntoResponse > {
91
- let version = match_version ( & mut conn, & name, & req_version)
92
- . await ?
93
- . assume_exact_name ( ) ?
94
- . into_canonical_req_version_or_else ( |version| {
95
- AxumNope :: Redirect (
96
- EscapedURI :: new ( & format ! ( "/crate/{name}/{version}/builds.json" ) , None ) ,
97
- CachePolicy :: ForeverInCdn ,
98
- )
99
- } ) ?
100
- . into_version ( ) ;
101
-
102
- Ok ( (
103
- Extension ( CachePolicy :: NoStoreMustRevalidate ) ,
104
- [ ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" ) ] ,
105
- Json (
106
- get_builds ( & mut conn, & name, & version)
107
- . await ?
108
- . iter ( )
109
- . filter_map ( |build| {
110
- if build. build_status == BuildStatus :: InProgress {
111
- return None ;
112
- }
113
- // for backwards compatibility in this API, we
114
- // * convert the build status to a boolean
115
- // * already filter out in-progress builds
116
- //
117
- // even when we start showing in-progress builds in the UI,
118
- // we might still not show them here for backwards
119
- // compatibility.
120
- Some ( serde_json:: json!( {
121
- "id" : build. id,
122
- "rustc_version" : build. rustc_version,
123
- "docsrs_version" : build. docsrs_version,
124
- "build_status" : build. build_status. is_success( ) ,
125
- "build_time" : build. build_time,
126
- } ) )
127
- } )
128
- . collect :: < Vec < _ > > ( ) ,
129
- ) ,
130
- )
131
- . into_response ( ) )
132
- }
133
-
134
85
async fn crate_version_exists (
135
86
conn : & mut sqlx:: PgConnection ,
136
87
name : & String ,
@@ -260,7 +211,6 @@ mod tests {
260
211
web:: cache:: CachePolicy ,
261
212
} ;
262
213
use axum:: { body:: Body , http:: Request } ;
263
- use chrono:: { DateTime , Utc } ;
264
214
use kuchikiki:: traits:: TendrilSink ;
265
215
use reqwest:: StatusCode ;
266
216
use tower:: ServiceExt ;
@@ -341,106 +291,6 @@ mod tests {
341
291
} ) ;
342
292
}
343
293
344
- #[ test]
345
- fn build_list_json ( ) {
346
- async_wrapper ( |env| async move {
347
- env. fake_release ( )
348
- . await
349
- . name ( "foo" )
350
- . version ( "0.1.0" )
351
- . builds ( vec ! [
352
- FakeBuild :: default ( )
353
- . rustc_version( "rustc (blabla 2019-01-01)" )
354
- . docsrs_version( "docs.rs 1.0.0" ) ,
355
- FakeBuild :: default ( )
356
- . successful( false )
357
- . rustc_version( "rustc (blabla 2020-01-01)" )
358
- . docsrs_version( "docs.rs 2.0.0" ) ,
359
- FakeBuild :: default ( )
360
- . rustc_version( "rustc (blabla 2021-01-01)" )
361
- . docsrs_version( "docs.rs 3.0.0" ) ,
362
- FakeBuild :: default ( )
363
- . build_status( BuildStatus :: InProgress )
364
- . rustc_version( "rustc (blabla 2022-01-01)" )
365
- . docsrs_version( "docs.rs 4.0.0" ) ,
366
- ] )
367
- . create ( )
368
- . await ?;
369
-
370
- let response = env
371
- . web_app ( )
372
- . await
373
- . get ( "/crate/foo/0.1.0/builds.json" )
374
- . await ?;
375
- response. assert_cache_control ( CachePolicy :: NoStoreMustRevalidate , & env. config ( ) ) ;
376
- let value: serde_json:: Value = serde_json:: from_str ( & response. text ( ) . await ?) ?;
377
-
378
- assert_eq ! ( value. as_array( ) . unwrap( ) . len( ) , 3 ) ;
379
-
380
- assert_eq ! ( value. pointer( "/0/build_status" ) , Some ( & true . into( ) ) ) ;
381
- assert_eq ! (
382
- value. pointer( "/0/docsrs_version" ) ,
383
- Some ( & "docs.rs 3.0.0" . into( ) )
384
- ) ;
385
- assert_eq ! (
386
- value. pointer( "/0/rustc_version" ) ,
387
- Some ( & "rustc (blabla 2021-01-01)" . into( ) )
388
- ) ;
389
- assert ! ( value. pointer( "/0/id" ) . unwrap( ) . is_i64( ) ) ;
390
- assert ! (
391
- serde_json:: from_value:: <DateTime <Utc >>(
392
- value. pointer( "/0/build_time" ) . unwrap( ) . clone( )
393
- )
394
- . is_ok( )
395
- ) ;
396
-
397
- assert_eq ! ( value. pointer( "/1/build_status" ) , Some ( & false . into( ) ) ) ;
398
- assert_eq ! (
399
- value. pointer( "/1/docsrs_version" ) ,
400
- Some ( & "docs.rs 2.0.0" . into( ) )
401
- ) ;
402
- assert_eq ! (
403
- value. pointer( "/1/rustc_version" ) ,
404
- Some ( & "rustc (blabla 2020-01-01)" . into( ) )
405
- ) ;
406
- assert ! ( value. pointer( "/1/id" ) . unwrap( ) . is_i64( ) ) ;
407
- assert ! (
408
- serde_json:: from_value:: <DateTime <Utc >>(
409
- value. pointer( "/1/build_time" ) . unwrap( ) . clone( )
410
- )
411
- . is_ok( )
412
- ) ;
413
-
414
- assert_eq ! ( value. pointer( "/2/build_status" ) , Some ( & true . into( ) ) ) ;
415
- assert_eq ! (
416
- value. pointer( "/2/docsrs_version" ) ,
417
- Some ( & "docs.rs 1.0.0" . into( ) )
418
- ) ;
419
- assert_eq ! (
420
- value. pointer( "/2/rustc_version" ) ,
421
- Some ( & "rustc (blabla 2019-01-01)" . into( ) )
422
- ) ;
423
- assert ! ( value. pointer( "/2/id" ) . unwrap( ) . is_i64( ) ) ;
424
- assert ! (
425
- serde_json:: from_value:: <DateTime <Utc >>(
426
- value. pointer( "/2/build_time" ) . unwrap( ) . clone( )
427
- )
428
- . is_ok( )
429
- ) ;
430
-
431
- assert ! (
432
- value. pointer( "/1/build_time" ) . unwrap( ) . as_str( ) . unwrap( )
433
- < value. pointer( "/0/build_time" ) . unwrap( ) . as_str( ) . unwrap( )
434
- ) ;
435
- assert ! (
436
- value. pointer( "/2/build_time" ) . unwrap( ) . as_str( ) . unwrap( )
437
- < value. pointer( "/1/build_time" ) . unwrap( ) . as_str( ) . unwrap( )
438
- ) ;
439
-
440
- Ok ( ( ) )
441
- } ) ;
442
- }
443
-
444
294
#[ test]
445
295
fn build_trigger_rebuild_missing_config ( ) {
446
296
async_wrapper ( |env| async move {
@@ -716,7 +566,7 @@ mod tests {
716
566
717
567
env. web_app ( )
718
568
. await
719
- . assert_success ( "/crate/aquarelle/latest/builds .json" )
569
+ . assert_success ( "/crate/aquarelle/latest/status .json" )
720
570
. await ?;
721
571
722
572
Ok ( ( ) )
0 commit comments