Skip to content

Commit

Permalink
Fix default settings for local demo
Browse files Browse the repository at this point in the history
Ideally, people should be able to clone this repo and get a quick
demonstration whether or not they actually have GnuCash installed.

We fix the path to the demo database, but also just turn off quote
fetching.

I notably haven't actually changed the test database to use the new
definition of "core four," so it's pretty far off. I'll have to change
that later!
  • Loading branch information
DavidCain committed Dec 30, 2021
1 parent 819a6ab commit f5ad9c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
birthday = '1972-07-12'

[gnucash]
path_to_book = 'example/sqlite3.gnucash'
path_to_book = '/home/linus/sqlite3.gnucash'
file_format = 'sqlite3'
update_prices = true # Only supported for SQLite
12 changes: 7 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ impl Config {
birthday: String::from("1985-01-01"),
},
gnucash: GnuCash {
path_to_book: String::from("example.sqlite3"),
path_to_book: String::from("example/sqlite3.gnucash"),
file_format: String::from("sqlite3"),
update_prices: true,
// This requires GnuCash to be installed.
// So that people can demo with *just* Rust, assume it's off by default.
update_prices: false,
},
}
}
Expand Down Expand Up @@ -87,7 +89,7 @@ mod tests {
fn test_parse_from_toml() {
let conf = Config::from_file("example_config.toml");
assert_eq!(conf.user_birthday(), NaiveDate::from_ymd(1972, 7, 12));
assert_eq!(&conf.gnucash.path_to_book, "example/sqlite3.gnucash");
assert_eq!(&conf.gnucash.path_to_book, "/home/linus/sqlite3.gnucash");
assert_eq!(&conf.gnucash.file_format, "sqlite3");
assert_eq!(conf.gnucash.update_prices, true);
}
Expand All @@ -96,8 +98,8 @@ mod tests {
fn test_fallback_to_default_settings() {
let conf = Config::from_file("/tmp/definitely_does_not_exist.toml");
assert_eq!(&conf.user.birthday, "1985-01-01");
assert_eq!(&conf.gnucash.path_to_book, "example.sqlite3");
assert_eq!(&conf.gnucash.path_to_book, "example/sqlite3.gnucash");
assert_eq!(&conf.gnucash.file_format, "sqlite3");
assert_eq!(conf.gnucash.update_prices, true);
assert_eq!(conf.gnucash.update_prices, false);
}
}

0 comments on commit f5ad9c6

Please sign in to comment.