Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard committed Feb 13, 2024
1 parent 67f0fe4 commit 4451d60
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/effects/effects_for_account_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,19 @@ mod tests {
"https://horizon-testnet.stellar.org/effects"
);
}

#[test]
fn test_ledgers_request_with_params() {
let request = EffectsForAccountRequest::new()
.set_account_id("GBL3QJ2MB3KJ7YV7YVXJ5ZL5V6Z5ZL5V6Z5ZL5V6Z5ZL5V6Z5ZL5V6Z".to_string())
.set_cursor(1)
.unwrap()
.set_limit(10)
.unwrap()
.set_order(Order::Desc);
assert_eq!(
request.build_url("https://horizon-testnet.stellar.org"),
"https://horizon-testnet.stellar.org/effects?account=GBL3QJ2MB3KJ7YV7YVXJ5ZL5V6Z5ZL5V6Z5ZL5V6Z5ZL5V6Z5ZL5V6Z&cursor=1&limit=10&order=desc"
);
}
}
32 changes: 32 additions & 0 deletions src/effects/effects_for_liquidity_pools_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,35 @@ impl Request for EffectsForLiquidityPoolsRequest {
)
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::BuildQueryParametersExt;

#[test]
fn test_effects_for_liquidity_pools_request() {
let request = EffectsForLiquidityPoolsRequest::new()
.set_liquidity_pool_id("liquidity_pool_id".to_string())
.set_cursor(1)
.unwrap()
.set_limit(10)
.unwrap()
.set_order(Order::Asc);

let url = request.build_url("https://horizon-testnet.stellar.org");
let query_parameters = vec![
Some("liquidity_pool_id=liquidity_pool_id".to_string()),
Some("cursor=1".to_string()),
Some("limit=10".to_string()),
Some("order=asc".to_string()),
]
.build_query_parameters();

assert_eq!(
url,
"https://horizon-testnet.stellar.org/effects?liquidity_pool_id=liquidity_pool_id&cursor=1&limit=10&order=asc"
);
assert_eq!(query_parameters, "?liquidity_pool_id=liquidity_pool_id&cursor=1&limit=10&order=asc");
}
}

0 comments on commit 4451d60

Please sign in to comment.