Clean up testing using new builder methods on types

korrat
Dec 17, 2022, 9:00 AM
KBSTC23N5DUM6YI7L2NB7CERADNBLMM776SVOTIOP5S7COFTN77AC

Dependencies

  • [2] 2JBFREZG enable additional warnings
  • [3] NSWL54NM allow deriving pretty printing config from a set of directives
  • [4] ONRIF4V7 add basic snapshot test for pretty printer
  • [5] SJ6AFVZL remove const configuration in favor of runtime config
  • [*] QRIJE4AQ add a simple pretty printer for beancount directives
  • [*] 5S4MZHL5 pretty print decimals using icu

Change contents

  • edit in common/beancount-pretty-printer/tests/snapshotting.rs at line 9
    [3.32][2.22600:22637](),[3.32][3.196:226](),[2.22637][3.196:226](),[3.196][3.196:226]()
    use beancount_types::Flag::Complete;
    use beancount_types::Posting;
  • edit in common/beancount-pretty-printer/tests/snapshotting.rs at line 11
    [3.338]
    [3.338]
    use tap::Tap as _;
    use time::macros::date;
  • replacement in common/beancount-pretty-printer/tests/snapshotting.rs at line 16
    [3.381][3.33:1214]()
    let directives = [Directive::Transaction(Transaction {
    date: time::macros::date!(2022 - 03 - 07),
    flag: Complete,
    payee: None,
    narration: None,
    postings: vec![
    Posting {
    flag: None,
    account: Account::try_from("Assets:Checking").unwrap(),
    amount: Some(Amount {
    amount: dec!(-010000.00),
    commodity: Commodity::try_from("EUR").unwrap(),
    }),
    cost: None,
    price: None,
    },
    Posting {
    flag: None,
    account: Account::try_from("Assets:Wallet").unwrap(),
    amount: Some(Amount {
    amount: dec!(9000.00),
    commodity: Commodity::try_from("EUR").unwrap(),
    }),
    cost: None,
    price: None,
    },
    Posting {
    flag: None,
    account: Account::try_from("Expenses:Banking:Fees").unwrap(),
    amount: None,
    cost: None,
    price: None,
    },
    ],
    })];
    [3.381]
    [3.1214]
    let directives = [Directive::from(
    Transaction::on(date!(2022 - 03 - 07)).tap_mut(|transaction| {
    let commodity = Commodity::try_from("EUR").unwrap();
    transaction
    .build_posting(Account::try_from("Assets:Checking").unwrap(), |posting| {
    posting.set_amount(Amount::new(dec!(-10000.00), commodity));
    })
    .build_posting(Account::try_from("Assets:Wallet").unwrap(), |posting| {
    posting.set_amount(Amount::new(dec!(9000.00), commodity));
    })
    .build_posting(Account::try_from("Expenses:Banking:Fees").unwrap(), |_| {});
    }),
    )];
  • edit in common/beancount-pretty-printer/Cargo.toml at line 31
    [8.1911]
    [3.2264]
    tap.workspace = true