feat!: Account features
- Bump version to 0.2.0
- Added trait SquadObject
- Implemented SquadObject for Quest and Account
- Implemented Config::load_accounts
- Removed src/quest/error.rs
- Added account tests in tests/main.rs
BREAKING CHANGE: Quest::{load,delete,save} are now provided by
SquadObject trait
This commit is contained in:
parent
1dc7d94785
commit
0e8cdde697
12 changed files with 285 additions and 98 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use squad_quest::{config::Config, quest::Quest};
|
||||
use squad_quest::{account::Account, config::Config, quest::Quest};
|
||||
|
||||
static CONFIG_PATH: &str = "./tests/main/config.toml";
|
||||
|
||||
|
|
@ -43,3 +43,41 @@ fn quest_one() {
|
|||
|
||||
assert_eq!(*quest, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_accounts() {
|
||||
let config = Config::load(CONFIG_PATH.into());
|
||||
let accounts = config.load_accounts();
|
||||
|
||||
assert_eq!(accounts.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_account_is_default() {
|
||||
let config = Config::load(CONFIG_PATH.into());
|
||||
let accounts = config.load_accounts();
|
||||
|
||||
let default = Account::default();
|
||||
|
||||
let account = accounts.iter().find(|a| a.id == default.id).unwrap();
|
||||
|
||||
assert_eq!(*account, default);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn account_test() {
|
||||
let config = Config::load(CONFIG_PATH.into());
|
||||
|
||||
let expected = Account {
|
||||
id: "test".to_string(),
|
||||
balance: 150,
|
||||
location: 0,
|
||||
quests_completed: vec![0],
|
||||
rooms_unlocked: Vec::new()
|
||||
};
|
||||
|
||||
let accounts = config.load_accounts();
|
||||
let account = accounts.iter().find(|a| a.id == expected.id).unwrap();
|
||||
|
||||
assert_eq!(*account, expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue