Skip to content

Commit

Permalink
fix: api changes to resolve overlapping imports
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Oct 8, 2021
1 parent ccc9329 commit 6eb5b05
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*,
Expand Down
44 changes: 44 additions & 0 deletions tests/plan_interval.rs
Original file line number Diff line number Diff line change
@@ -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();
});
}

0 comments on commit 6eb5b05

Please sign in to comment.