@@ -984,13 +984,63 @@ mod tests {
984984 . await ;
985985 }
986986
987+ #[ tokio:: test]
987988 async fn get_status_page_data ( ) {
988989 run_postgres_test ( |ctx| async {
989990 let db = ctx. db_client ( ) . connection ( ) . await ;
990- db. add_collector_config ( "collector-1" , & Target :: X86_64UnknownLinuxGnu , 1 , true )
991+ let benchmark_set = BenchmarkSet ( 0u32 ) ;
992+ let time = chrono:: DateTime :: from_str ( "2021-09-01T00:00:00.000Z" ) . unwrap ( ) ;
993+ let tag = "sha-1" ;
994+ let collector_name = "collector-1" ;
995+ let target = Target :: X86_64UnknownLinuxGnu ;
996+
997+ db. add_collector_config ( collector_name, & target, benchmark_set. 0 , true )
998+ . await
999+ . unwrap ( ) ;
1000+
1001+ let benchmark_request = BenchmarkRequest :: create_release ( tag, time) ;
1002+ db. insert_benchmark_request ( & benchmark_request)
1003+ . await
1004+ . unwrap ( ) ;
1005+
1006+ /* Create job for the request */
1007+ db. enqueue_benchmark_job (
1008+ benchmark_request. tag ( ) . unwrap ( ) ,
1009+ & target,
1010+ & CodegenBackend :: Llvm ,
1011+ & Profile :: Opt ,
1012+ benchmark_set. 0 ,
1013+ )
1014+ . await
1015+ . unwrap ( ) ;
1016+
1017+ let job = db
1018+ . dequeue_benchmark_job ( collector_name, & target, & benchmark_set)
9911019 . await
1020+ . unwrap ( )
9921021 . unwrap ( ) ;
9931022
1023+ assert_eq ! ( job. request_tag( ) , benchmark_request. tag( ) . unwrap( ) ) ;
1024+
1025+ /* Mark the job as complete */
1026+ db. mark_benchmark_job_as_completed ( job. id ( ) , & BenchmarkJobConclusion :: Success )
1027+ . await
1028+ . unwrap ( ) ;
1029+
1030+ // record a couple of errors against the tag
1031+ let artifact_id = db. artifact_id ( & ArtifactId :: Tag ( tag. to_string ( ) ) ) . await ;
1032+
1033+ db. record_error ( artifact_id, "example-1" , "This is an error" )
1034+ . await ;
1035+ db. record_error ( artifact_id, "example-2" , "This is another error" )
1036+ . await ;
1037+
1038+ db. mark_benchmark_request_as_completed ( tag) . await . unwrap ( ) ;
1039+
1040+ let status_page_data = db. get_status_page_data ( ) . await . unwrap ( ) ;
1041+
1042+ dbg ! ( "{:?}" , status_page_data) ;
1043+
9941044 Ok ( ctx)
9951045 } )
9961046 . await ;
0 commit comments