Skip to content

Commit

Permalink
fix panics and derive Debug for Market responses
Browse files Browse the repository at this point in the history
  • Loading branch information
elpiel committed Oct 20, 2020
1 parent bc271c6 commit ecaf051
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct MarketApi {
logger: Logger,
}

#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdSlotResponse {
pub slot: AdSlot,
Expand All @@ -28,7 +28,7 @@ pub struct AdSlotResponse {
pub alexa_rank: Option<f64>,
}

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdUnitResponse {
pub unit: AdUnit,
Expand Down
9 changes: 5 additions & 4 deletions src/units_for_slot_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use chrono::{TimeZone, Utc};
use http::request::Request;
use hyper::{Body, Response};
use hyper::Body;
use primitives::{
supermarket::units_for_slot::response::{
AdUnit, Campaign as ResponseCampaign, Channel as ResponseChannel, Spec as ResponseSpec,
Expand Down Expand Up @@ -147,7 +147,8 @@ mod units_for_slot_tests {
archived: false,
created: Utc.timestamp(1_564_383_600, 0),
description: Some("test slot".to_string()),
fallback_unit: Some("QmTAF3FsFDS7Ru8WChoD9ofiHTH8gAQfR4mYSnwxqTDpJH".to_string()),
// fallback_unit: Some("QmTAF3FsFDS7Ru8WChoD9ofiHTH8gAQfR4mYSnwxqTDpJH".to_string()),
fallback_unit: None,
min_per_impression: Some(min_per_impression),
modified: Some(Utc.timestamp(1_564_383_600, 0)),
owner: ValidatorId::try_from("0xB7d3F81E857692d13e9D63b232A90F4A1793189E")
Expand Down Expand Up @@ -227,7 +228,7 @@ mod units_for_slot_tests {
let mock_slot = get_mock_slot();

Mock::given(method("GET"))
.and(path(format!("/units/{}", mock_slot.slot.ipfs)))
.and(path("/units"))
.respond_with(ResponseTemplate::new(200).set_body_json(&mock_units))
.mount(&server)
.await;
Expand All @@ -250,7 +251,7 @@ mod units_for_slot_tests {

assert_eq!(http::StatusCode::OK, actual_response.status());

let units_for_slot: UnitsForSlotResponse = serde_json::from_slice(&hyper::body::to_bytes(actual_response).await.unwrap()).expect("Should deserialize");// ).await.expect("Should concatenate")
let units_for_slot: UnitsForSlotResponse = serde_json::from_slice(&hyper::body::to_bytes(actual_response).await.unwrap()).expect("Should deserialize");

assert_eq!(expected_response.campaigns.len(), units_for_slot.campaigns.len());
}
Expand Down

0 comments on commit ecaf051

Please sign in to comment.