From 6eb5b059c48a4148482af3b5cb7c63e5dca80c25 Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Fri, 8 Oct 2021 13:30:26 +0100 Subject: [PATCH] fix: api changes to resolve overlapping imports --- CONTRIBUTING.md | 2 +- src/resources.rs | 9 ++++++++- tests/plan_interval.rs | 44 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/plan_interval.rs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1266feed8..4859fa748 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,7 +64,7 @@ to run a [`stripe-mock`](https://github.com/stripe/stripe-mock) server and selec ```sh docker run --rm -d -it -p 12111-12112:12111-12112 stripemock/stripe-mock:latest -cargo test --features runtime-async-std-surf +cargo test --features runtime-blocking ``` ## Communication diff --git a/src/resources.rs b/src/resources.rs index d7569bd83..229656b1c 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -152,10 +152,17 @@ pub use { invoiceitem::*, line_item::*, plan::*, + plan::PlanInterval, price::*, promotion_code::*, - subscription::*, subscription_item::*, + subscription_item::PlanInterval as SubscriptionItemInterval, + subscription_item::SubscriptionItemPriceDataRecurring as SubscriptionItemPriceDataRecurring, + // need to import this afterwards so that the SubscriptionItemPriceDataRecurring + // isn't silently ignored + subscription::*, + subscription::PlanInterval as SubscriptionInterval, + subscription::SubscriptionItemPriceDataRecurring as SubscriptionPriceDataRecurring, subscription_schedule::*, tax_id::*, tax_rate::*, diff --git a/tests/plan_interval.rs b/tests/plan_interval.rs new file mode 100644 index 000000000..5c30952f5 --- /dev/null +++ b/tests/plan_interval.rs @@ -0,0 +1,44 @@ +//! Basic tests to ensure that the plan interval types +//! are exported properly. Mainly just needs to compile. + +mod mock; + +#[test] +#[cfg(feature = "blocking")] +fn can_create_plan() { + let id = "price_123".parse().unwrap(); + mock::with_client(|client| { + let mut plan = stripe::Plan::retrieve(client, &id, &[]).unwrap(); + plan.interval = Some(stripe::PlanInterval::Month); + }); +} + +#[test] +#[cfg(feature = "blocking")] +fn can_create_subscription_interval() { + let recurring = stripe::SubscriptionPriceDataRecurring { + interval: stripe::SubscriptionInterval::Month, + interval_count: Some(100), + }; +} + +#[test] +#[cfg(feature = "blocking")] +fn can_create_subscription_plan_interval() { + mock::with_client(|client| { + let id = "sub_123".parse().unwrap(); + let mut create = stripe::CreateSubscriptionItem::new(id); + create.price_data = Some(stripe::SubscriptionItemPriceData { + currency: stripe::Currency::USD, + product: "My Product".to_string(), + recurring: stripe::SubscriptionItemPriceDataRecurring { + interval: stripe::SubscriptionItemInterval::Day, + interval_count: Some(6), + }, + tax_behavior: None, + unit_amount: None, + unit_amount_decimal: None, + }); + let result = stripe::SubscriptionItem::create(client, create).unwrap(); + }); +}