Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtbuilds committed Dec 19, 2023
1 parent d6917e6 commit dcaf90c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/src/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub fn extract_operation_doc(operation: &oa::Operation, format: DocFormat) -> Op
}

pub fn extract_schema_docs(schema: &Schema) -> Option<Doc> {
dbg!(schema);
schema
.schema_data
.description
Expand Down
4 changes: 2 additions & 2 deletions libninja/src/rust/lower_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion libninja/tests/all_of/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(schema).unwrap();
let mut record = ln_core::extractor::create_record(name, &schema, spec);
record.clear_docs();
record
}

Expand All @@ -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);
}

Expand Down
18 changes: 18 additions & 0 deletions libninja/tests/all_of/transaction.rs
Original file line number Diff line number Diff line change
@@ -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<chrono::NaiveDate>,
/**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<chrono::DateTime<chrono::Utc>>,
///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<Vec<String>>,
/**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<chrono::DateTime<chrono::Utc>>,
/**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<String>,
///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<String>,
pub transaction_code: String,
Expand Down

0 comments on commit dcaf90c

Please sign in to comment.