test loading AppSession

This commit is contained in:
jfmonty2 committed 2026-11-18 10:14:36 -05:00
1 parent 0798124811
commit 5999aba0a5
2 files changed
+44 -14

No files matched your search

+19 -14
View File
@@ -18,10 +18,6 @@ impl AppSession {
AppSession::Empty
}
}
pub fn unlock(&mut self, passphrase: &str) -> Result<AppSession, CreddyError> {
todo!()
}
}
impl Global for AppSession {}
@@ -29,15 +25,24 @@ impl Global for AppSession {}
#[cfg(test)]
mod tests {
use super::*;
use std::assert_matches;
use testresult::TestResult;
use crate::test_data::TestEnv;
// #[test]
// fn test_new() {
// let passphrase = "correct horse battery staple";
// let salt = AppSession::salt().expect("salt generation failed.");
// let session = AppSession::new(passphrase, &salt).expect("password KDF failed.");
// match session {
// AppSession::Unlocked { .. } => (),
// _ => panic!("AppSession::new() should return an unlocked session"),
// }
// }
#[test]
fn test_load_empty() -> TestResult {
let env = TestEnv::new()?;
let session = AppSession::load(&env.config);
assert_matches!(session, AppSession::Empty);
Ok(())
}
#[test]
fn test_load_locked() -> TestResult {
let env = TestEnv::new()?;
let _ = env.db()?; // creates the database in the temp dir
let session = AppSession::load(&env.config);
assert_matches!(session, AppSession::Locked);
Ok(())
}
}