app init test
[?]
May 20, 2025, 7:19 PM
VCNKFNUF7OWVSWC6I5D25KUZ3XZZICZ3LHWVPF2N5ZSP7LQ2JOUQCDependencies
- [2]
6YZAVBWUInitial commit - [3]
KLR5FRIBadd fs state read/write of repos - [4]
IQDCHWCPload a pijul repo - [5]
WT3GA27Padd cursor with selection - [6]
EC3TVL4Xadd untracked files - [7]
KT5UYXGKfix selection after adding file, add changed file diffs - [8]
YBJRDOTCmake all repo actions async - [9]
2VUX5BTDload identity - [10]
A5YBC77Vrecord! - [11]
AMPZ2BXKshow changed files diffs (only Edit atm) - [12]
6SW7UVSHupdate iced version - [13]
HOJZI52Yrename flowers_ui to inflorescence - [14]
WI2BVQ6Jrm client lib crate - [15]
CALXOZXAflatten crates dir - [16]
BFN2VHZSrefactor file stuff into sub-mod - [17]
3SYSJKYLadd app icon - [18]
23SFYK4Qbig view refactor into a new crate - [19]
OPXFZKEBview tests setup - [20]
WGID4LS4absolutely slayed testing with iced task - [21]
UB2ITZJSrefresh changed files on FS changes - [22]
SWWE2R6Mdisplay basic repo stuff - [23]
NWJD6VM6mv libflowers libflorescence - [24]
OQ6HSAWHshow record log
Change contents
- file addition: testing.rs[15.31]
use chrono::Utc;use derivative::Derivative;use libpijul::key::SKey;use pijul_identity::Credentials;use pijul_repository::Repository;use tempfile::{tempdir, TempDir};/// Setup a Pijul ID in a temp dir. Sets `PIJUL_CONFIG_DIR` env var, which is/// used by pijul when loading IDpub fn setup_pijul_id() -> PijulId {let dir = tempdir().unwrap();unsafe { std::env::set_var("PIJUL_CONFIG_DIR", &dir.path().as_os_str()) };let skey = SKey::generate(None);let secret_key = skey.save(None);let public_key = skey.public_key();let id = pijul_identity::Complete {name: "Fandan".to_string(),config: pijul_identity::Config {author: pijul_config::Author {username: "fandan".to_string(),display_name: "Fan Dan".to_string(),email: "fan@dan.com".to_string(),origin: "ssh.pijul.com".to_string(),key_path: None,},key_path: None,},last_modified: Utc::now(),public_key,// TODO what happens when this is None? Currently `identity::load` fails// as it needs to be able to read the keycredentials: Some(Credentials::new(secret_key, None)),};id.write().unwrap();PijulId { dir, skey }}/// Setup an empty Pijul repo in a temp dirpub fn setup_pijul_repo() -> PijulRepo {let dir = tempdir().unwrap();let repo =Repository::init(Some(dir.path().to_path_buf()), None, None).unwrap();let mut txn = repo.pristine.mut_txn_begin().unwrap();let channel_name = libpijul::DEFAULT_CHANNEL.to_string();libpijul::MutTxnT::open_or_create_channel(&mut txn, &channel_name).unwrap();libpijul::MutTxnT::set_current_channel(&mut txn, &channel_name).unwrap();libpijul::MutTxnT::commit(txn).unwrap();PijulRepo { dir }}#[derive(Derivative)]#[derivative(Debug)]pub struct PijulId {pub dir: TempDir,#[derivative(Debug = "ignore")]pub skey: SKey,}#[derive(Debug)]pub struct PijulRepo {pub dir: TempDir,} - edit in libflorescence/src/lib.rs at line 9[14.618]
#[cfg(any(test, feature = "testing"))]pub mod testing; - edit in libflorescence/Cargo.toml at line 19
testing = ["pijul-config", "tempfile"] - edit in libflorescence/Cargo.toml at line 66
workspace = true# "testing" feature dependencies[dependencies.pijul-config]workspace = trueoptional = true[dependencies.tempfile] - edit in libflorescence/Cargo.toml at line 74[8.4672]
optional = true[dev-dependencies][dev-dependencies.pijul-config]workspace = true[dev-dependencies.tempfile]workspace = true - file addition: test.rs[15.364]
use crate::{init, task, Msg};use libflorescence::repo;use libflorescence::testing::{setup_pijul_id, setup_pijul_repo};#[tokio::test]async fn test_init() {let _id = setup_pijul_id();let repo = setup_pijul_repo();let repo_path = repo.dir.path();let (state, mut tasks) = init(repo_path.to_path_buf());assert_eq!(state.repo_path, repo_path);// Must receive 3 messages:// - Msg::WindowOpened// - Msg::LoadedId// - Msg::FromRepo(repo::MsgOut::Init)let msg_0 = task::await_next_msg(&mut tasks).await.unwrap();let msg_1 = task::await_next_msg(&mut tasks).await.unwrap();let msg_2 = task::await_next_msg(&mut tasks).await.unwrap();let mut window_opened = false;let mut loaded_id = false;let mut inited_repo = false;for msg in [msg_0, msg_1, msg_2] {if !window_opened && matches!(msg, Msg::WindowOpened(_)) {window_opened = true;continue;}if !loaded_id && matches!(msg, Msg::LoadedId(_)) {loaded_id = true;continue;}if !inited_repo && matches!(msg, Msg::FromRepo(repo::MsgOut::Init(_))) {inited_repo = true;continue;}}let all = [window_opened, loaded_id, inited_repo];if !all.iter().all(|success| *success) {panic!("Some task didn't complete {all:#?}")}} - replacement in inflorescence/src/task.rs at line 17
pub async fn await_next_result<T>(tasks: &mut Task<T>) -> Option<T> {pub async fn await_next_msg<T>(tasks: &mut Task<T>) -> Option<T> { - replacement in inflorescence/src/task.rs at line 139
let result = await_next_result(&mut task).await;let result = await_next_msg(&mut task).await; - edit in inflorescence/src/main.rs at line 6
#[cfg(test)]mod test; - replacement in inflorescence/src/main.rs at line 51
iced::daemon(init, update, view)let repo_path = PathBuf::from("/home/tz/dev/pijul");iced::daemon(move || init(repo_path.clone()), update, view) - replacement in inflorescence/src/main.rs at line 59
fn init() -> (State, Task<Msg>) {fn init(repo_path: PathBuf) -> (State, Task<Msg>) { - edit in inflorescence/src/main.rs at line 62
// TODO: `include_bytes!`? - edit in inflorescence/src/main.rs at line 64
// TODO: `include_bytes!`? - edit in inflorescence/src/main.rs at line 66
let repo_path = PathBuf::from("/home/tz/dev/pijul"); - edit in inflorescence/Cargo.toml at line 37
# Internal dependencies[dev-dependencies.libflorescence]workspace = truefeatures = ["testing"]# External dependencies[dev-dependencies.assert_matches]workspace = true - edit in Cargo.toml at line 21
[workspace.dependencies.assert_matches]version = "1" - edit in Cargo.toml at line 54
[workspace.dependencies.pijul-config]path = "../pijul/pijul-config" - edit in Cargo.toml at line 71
[workspace.dependencies.tempfile]version = "3" - edit in Cargo.lock at line 208
name = "assert_matches"version = "1.5.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"[[package]] - edit in Cargo.lock at line 2724
"assert_matches", - edit in Cargo.lock at line 2980
"pijul-config", - edit in Cargo.lock at line 2987
"tempfile", - replacement in Cargo.lock at line 3589
"proc-macro-crate 1.3.1","proc-macro-crate 3.3.0", - replacement in Cargo.lock at line 5765
"rand 0.7.3","rand 0.8.5",