add market and odds endpoints
This commit is contained in:
@@ -129,3 +129,56 @@ async fn feed_next_returns_a_manifestable_event() {
|
||||
assert!(manifest["media"].as_array().unwrap().len() >= 1);
|
||||
assert!(manifest["markets"].as_array().unwrap().len() >= 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn event_markets_and_current_odds_work() {
|
||||
let app = build_router(AppState::new(AppConfig::default(), None, None));
|
||||
|
||||
let event_response = app
|
||||
.clone()
|
||||
.oneshot(Request::builder().uri("/api/v1/feed/next").body(Body::empty()).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let event_body = to_bytes(event_response.into_body(), usize::MAX).await.unwrap();
|
||||
let event: json::Value = json::from_slice(&event_body).unwrap();
|
||||
let event_id = event["id"].as_str().unwrap().to_string();
|
||||
|
||||
let markets_response = app
|
||||
.clone()
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri(format!("/api/v1/events/{event_id}/markets"))
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(markets_response.status(), StatusCode::OK);
|
||||
|
||||
let markets_body = to_bytes(markets_response.into_body(), usize::MAX).await.unwrap();
|
||||
let markets: json::Value = json::from_slice(&markets_body).unwrap();
|
||||
let market_id = markets[0]["id"].as_str().unwrap().to_string();
|
||||
|
||||
assert_eq!(markets[0]["outcomes"].as_array().unwrap().len(), 2);
|
||||
|
||||
let odds_response = app
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri(format!("/api/v1/markets/{market_id}/odds/current"))
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(odds_response.status(), StatusCode::OK);
|
||||
|
||||
let odds_body = to_bytes(odds_response.into_body(), usize::MAX).await.unwrap();
|
||||
let odds: json::Value = json::from_slice(&odds_body).unwrap();
|
||||
|
||||
assert_eq!(odds["market_id"], market_id);
|
||||
assert_eq!(odds["is_current"], true);
|
||||
assert_eq!(odds["odds"].as_array().unwrap().len(), 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user