test: Quests Create/Read/Update/Delete
This commit is contained in:
parent
01d3755ea6
commit
f5180a559b
3 changed files with 40 additions and 0 deletions
29
tests/io.rs
Normal file
29
tests/io.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use squad_quest::{config::Config,quest::{error::{QuestError}, Quest}};
|
||||
use std::path::PathBuf;
|
||||
|
||||
const CONFIG_PATH: &str = "tests/io/config.toml";
|
||||
|
||||
// Note: Quest::delete uses Quest::load underneath,
|
||||
// and Quest::save can override files,
|
||||
// so this test covers full quest CRUD
|
||||
#[test]
|
||||
fn quest_crud() -> Result<(), QuestError> {
|
||||
let config = Config::load(CONFIG_PATH.into());
|
||||
|
||||
let mut quests_path = PathBuf::from(CONFIG_PATH).parent().unwrap().to_owned();
|
||||
quests_path.push(config.quests_path);
|
||||
|
||||
let quest = Quest::default();
|
||||
|
||||
println!("{:?}", quests_path.clone());
|
||||
|
||||
quest.save(quests_path.clone())?;
|
||||
|
||||
let filename = format!("{}.toml", quest.id);
|
||||
|
||||
let delete_path = quests_path.with_file_name(filename);
|
||||
|
||||
Quest::delete(delete_path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue