Skip to content

Commit

Permalink
Fix tests client #102
Browse files Browse the repository at this point in the history
  • Loading branch information
jpraynaud committed Apr 12, 2022
1 parent 1d17a50 commit 27f3ac9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mithril-network/mithril-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ mod tests {

#[tokio::test]
async fn test_list_snapshots_ok() {
let config = Config {
network: "testnet".to_string(),
aggregator_endpoint: "http://endpoint".to_string(),
};
let fake_snapshots = get_fake_snapshots();
let mut mock_aggregator_handler = MockAggregatorHandler::new();
mock_aggregator_handler
.expect_list_snapshots()
.return_const(Ok(fake_snapshots.clone()))
.once();
let mut client = Client::new();
let mut client = Client::new(Arc::new(config));
client.with_aggregator_handler(mock_aggregator_handler);
let snapshots = client.list_snapshots().await;
snapshots.as_ref().expect("unexpected error");
Expand All @@ -104,12 +108,16 @@ mod tests {

#[tokio::test]
async fn test_list_snapshots_ko() {
let config = Config {
network: "testnet".to_string(),
aggregator_endpoint: "http://endpoint".to_string(),
};
let mut mock_aggregator_handler = MockAggregatorHandler::new();
mock_aggregator_handler
.expect_list_snapshots()
.return_const(Err("error occurred".to_string()))
.once();
let mut client = Client::new();
let mut client = Client::new(Arc::new(config));
client.with_aggregator_handler(mock_aggregator_handler);
let snapshots = client.list_snapshots().await;
assert!(snapshots.is_err(), "an error should have occurred");
Expand Down

0 comments on commit 27f3ac9

Please sign in to comment.