From 4451d60d0c170d820cd3c82be1295edb75109e7f Mon Sep 17 00:00:00 2001 From: leonard Date: Tue, 13 Feb 2024 13:37:52 +0100 Subject: [PATCH] tests --- src/effects/effects_for_account_request.rs | 15 +++++++++ .../effects_for_liquidity_pools_request.rs | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/effects/effects_for_account_request.rs b/src/effects/effects_for_account_request.rs index 7475935..8c55142 100644 --- a/src/effects/effects_for_account_request.rs +++ b/src/effects/effects_for_account_request.rs @@ -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" + ); + } } diff --git a/src/effects/effects_for_liquidity_pools_request.rs b/src/effects/effects_for_liquidity_pools_request.rs index 3fdd5a6..c2ef682 100644 --- a/src/effects/effects_for_liquidity_pools_request.rs +++ b/src/effects/effects_for_liquidity_pools_request.rs @@ -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"); + } +} \ No newline at end of file