Skip to content

Commit

Permalink
getting checks to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Baldwin committed Jul 26, 2019
1 parent 0dee47f commit 8503511
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/async_create_charge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let client = stripe::r#async::Client::new(secret_key);

// Define a card to charge
let mut card = "card_189g322eZvKYlo2CeoPw2sdy".parse().expect("expected card to be valid");
let card = "card_189g322eZvKYlo2CeoPw2sdy".parse().expect("expected card to be valid");

// Define the charge
let mut params = stripe::CreateCharge::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/create_charge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let client = stripe::Client::new(secret_key);

// Define a card to charge
let mut card = "card_189g322eZvKYlo2CeoPw2sdy".parse().expect("expected card to be valid");
let card = "card_189g322eZvKYlo2CeoPw2sdy".parse().expect("expected card to be valid");

// Define the charge
let mut params = stripe::CreateCharge::new();
Expand Down
35 changes: 3 additions & 32 deletions tests/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn urldecode(input: String) -> String {

#[test]
fn deserialize_payment_source_params() {
use stripe::{CardParams, PaymentSourceParams, SourceId, TokenId};
use stripe::{PaymentSourceParams, SourceId, TokenId};

let examples = [
(
Expand All @@ -81,30 +81,18 @@ fn deserialize_payment_source_params() {
"tok_189g322eZvKYlo2CeoPw2sdy".parse::<TokenId>().unwrap(),
)),
),
// (
// json!({"object": "card", "exp_month": "12", "exp_year": "2017", "number": "1111222233334444"}),
// Some(PaymentSourceParams::Card(CardParams {
// exp_month: "12",
// exp_year: "2017",
// number: "1111222233334444",
// name: None,
// cvc: None,
// })),
// ),
// // Error: Missing `{"object": "card"}`
// (json!({"exp_month": "12", "exp_year": "2017", "number": "1111222233334444"}), None),
];

for (value, expected) in &examples {
let input = serde_json::to_string(value).unwrap();
let parsed: Option<PaymentSourceParams<'_>> = serde_json::from_str(&input).ok();
let parsed: Option<PaymentSourceParams> = serde_json::from_str(&input).ok();
assert_eq!(json!(parsed), json!(expected));
}
}

#[test]
fn serialize_payment_source_params() {
use stripe::{CardParams, PaymentSourceParams, SourceId, TokenId};
use stripe::{PaymentSourceParams, SourceId, TokenId};

let examples = [
(
Expand All @@ -115,23 +103,6 @@ fn serialize_payment_source_params() {
PaymentSourceParams::Token("tok_189g322eZvKYlo2CeoPw2sdy".parse::<TokenId>().unwrap()),
json!("tok_189g322eZvKYlo2CeoPw2sdy"),
),
// (
// PaymentSourceParams::Card(CardParams {
// exp_month: "12",
// exp_year: "2017",
// number: "1111222233334444",
// name: None,
// cvc: None,
// }),
// json!({
// "object": "card",
// "exp_month": "12",
// "exp_year": "2017",
// "number": "1111222233334444",
// "name": null,
// "cvc": null
// }),
// ),
];

for (params, expected) in &examples {
Expand Down

0 comments on commit 8503511

Please sign in to comment.