From dcaf90ceef47d75a27cc3712243f8368a1fb692f Mon Sep 17 00:00:00 2001 From: Kurt Wolf Date: Tue, 19 Dec 2023 15:02:08 -0500 Subject: [PATCH] update tests --- core/src/extractor.rs | 1 + libninja/src/rust/lower_mir.rs | 4 ++-- libninja/tests/all_of/main.rs | 2 +- libninja/tests/all_of/transaction.rs | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/src/extractor.rs b/core/src/extractor.rs index 677405e..f75e52e 100644 --- a/core/src/extractor.rs +++ b/core/src/extractor.rs @@ -199,6 +199,7 @@ pub fn extract_operation_doc(operation: &oa::Operation, format: DocFormat) -> Op } pub fn extract_schema_docs(schema: &Schema) -> Option { + dbg!(schema); schema .schema_data .description diff --git a/libninja/src/rust/lower_mir.rs b/libninja/src/rust/lower_mir.rs index 07c7c7d..bc20e33 100644 --- a/libninja/src/rust/lower_mir.rs +++ b/libninja/src/rust/lower_mir.rs @@ -340,10 +340,10 @@ mod tests { }], docs: None, }; - let code = create_newtype_struct(&schema); + let code = create_newtype_struct(&schema, &HirSpec::default()); let code = format_code(code).unwrap(); assert_eq!(&code, " -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct NewType(pub String); ".trim()); } diff --git a/libninja/tests/all_of/main.rs b/libninja/tests/all_of/main.rs index 10031b8..819dcf6 100644 --- a/libninja/tests/all_of/main.rs +++ b/libninja/tests/all_of/main.rs @@ -16,7 +16,6 @@ const RESTRICTION_BACS_RS: &str = include_str!("restriction_bacs.rs"); fn record_for_schema(name: &str, schema: &str, spec: &OpenAPI) -> Record { let schema = serde_yaml::from_str::(schema).unwrap(); let mut record = ln_core::extractor::create_record(name, &schema, spec); - record.clear_docs(); record } @@ -38,6 +37,7 @@ fn test_transaction() { extract_records(&spec, &mut result).unwrap(); let record = record_for_schema("Transaction", TRANSACTION, &spec); let code = formatted_code(record, &result); + println!("{}", code); assert_eq!(code, TRANSACTION_RS); } diff --git a/libninja/tests/all_of/transaction.rs b/libninja/tests/all_of/transaction.rs index 871556d..1c83cc3 100644 --- a/libninja/tests/all_of/transaction.rs +++ b/libninja/tests/all_of/transaction.rs @@ -1,18 +1,36 @@ +///A representation of a transaction #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct Transaction { #[serde(flatten)] pub transaction_base: TransactionBase, + ///The date that the transaction was authorized. Dates are returned in an [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format ( `YYYY-MM-DD` ). #[serde(skip_serializing_if = "Option::is_none")] pub authorized_date: Option, + /**Date and time when a transaction was authorized in [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format ( `YYYY-MM-DDTHH:mm:ssZ` ). + +This field is returned for select financial institutions and comes as provided by the institution. It may contain default time values (such as 00:00:00).*/ #[serde(skip_serializing_if = "Option::is_none")] pub authorized_datetime: Option>, + ///The counterparties present in the transaction. Counterparties, such as the financial institutions, are extracted by Plaid from the raw description. #[serde(skip_serializing_if = "Option::is_none")] pub counterparties: Option>, + /**Date and time when a transaction was posted in [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format ( `YYYY-MM-DDTHH:mm:ssZ` ). + +This field is returned for select financial institutions and comes as provided by the institution. It may contain default time values (such as 00:00:00).*/ #[serde(skip_serializing_if = "Option::is_none")] pub datetime: Option>, + /**The channel used to make a payment. +`online:` transactions that took place online. + +`in store:` transactions that were made at a physical location. + +`other:` transactions that relate to banks, e.g. fees or deposits. + +This field replaces the `transaction_type` field.*/ pub payment_channel: String, #[serde(skip_serializing_if = "Option::is_none")] pub personal_finance_category: Option, + ///A link to the icon associated with the primary personal finance category. The logo will always be 100x100 pixels. #[serde(skip_serializing_if = "Option::is_none")] pub personal_finance_category_icon_url: Option, pub transaction_code: String,