test got repo change

[?]
Jun 2, 2025, 5:14 PM
TSFQFCB2NXDOBLBRUSAT63VJIXLPPTJGSTIDNOTLGHVVWSHITRNQC

Dependencies

  • [2] ACDXXAX2 refactor main's updates into smaller fns
  • [3] I56UGW7U make record test, fix log update
  • [4] YYKXNBFL test: add untracked file
  • [5] ESMM3FEL test selection reindexing
  • [6] KMB6FND3 test view update fn rather than direct fn calls
  • [7] VCNKFNUF app init test
  • [8] ONRCENKT rm unnecessary state from repo's internal state
  • [9] AMPZ2BXK show changed files diffs (only Edit atm)
  • [*] 6YZAVBWU Initial commit

Change contents

  • replacement in inflorescence/src/test.rs at line 2
    [3.1320][5.34:106]()
    use crate::{cursor, init, reindex_selection, task, update, Msg, State};
    [3.1320]
    [3.1428]
    use crate::{
    cursor, init, reindex_selection, repo_got_change_diffs, task, update, Msg,
    State,
    };
  • replacement in inflorescence/src/test.rs at line 19
    [3.1682][4.34:66]()
    use std::collections::BTreeSet;
    [3.1682]
    [4.66]
    use std::collections::{BTreeMap, BTreeSet};
  • edit in inflorescence/src/test.rs at line 588
    [5.6464][5.6464:6625]()
    let change_hash = |bytes: &[u8]| {
    let mut hasher = pijul::pristine::Hasher::default();
    hasher.update(bytes);
    hasher.finish()
    };
  • edit in inflorescence/src/test.rs at line 655
    [5.8439]
    [3.4747]
    /// When a repo loads a change diff, it should only be used if the same change
    /// is still selected
    #[test(tokio::test)]
    async fn test_repo_got_change_diffs() {
    let TestState {
    mut state,
    tasks: _tasks,
    fs_watch_task: _,
    id: _,
    repo: _,
    } = setup_state().await;
    let change_hash_0 = change_hash(&[0]);
    let change_hash_1 = change_hash(&[1]);
    // _________________________________________________________________________
    // Case: nothing is selected
    assert!(state.cursor.selection.is_none());
    let diffs = BTreeMap::from_iter([]);
    let task = repo_got_change_diffs(&mut state, change_hash_0, diffs);
    assert!(task.is_none());
    assert!(state.cursor.selection.is_none());
    // _________________________________________________________________________
    // Case: selection is changed
    state.cursor.selection = Some(cursor::Selection::LogChange {
    ix: 0,
    hash: change_hash_0,
    message: "".to_string(),
    diffs: None,
    file: None,
    });
    let diffs = BTreeMap::from_iter([]);
    let task = repo_got_change_diffs(&mut state, change_hash_1, diffs);
    assert!(task.is_none());
    assert!(state.cursor.selection.is_some());
    assert_matches!(
    state.cursor.selection.as_ref().unwrap(),
    cursor::Selection::LogChange { diffs: None, .. }
    );
    // _________________________________________________________________________
    // Case: selection is still the same
    state.cursor.selection = Some(cursor::Selection::LogChange {
    ix: 0,
    hash: change_hash_1,
    message: "".to_string(),
    diffs: None,
    file: None,
    });
    let diffs = BTreeMap::from_iter([]);
    let task = repo_got_change_diffs(&mut state, change_hash_1, diffs);
    assert!(task.is_none());
    assert!(state.cursor.selection.is_some());
    assert_matches!(
    state.cursor.selection.as_ref().unwrap(),
    cursor::Selection::LogChange { diffs: Some(_), .. }
    );
    }
  • edit in inflorescence/src/test.rs at line 820
    [3.7650]
    [3.7650]
    }
    fn change_hash(bytes: &[u8]) -> pijul::Hash {
    let mut hasher = pijul::pristine::Hasher::default();
    hasher.update(bytes);
    hasher.finish()
  • replacement in inflorescence/src/main.rs at line 628
    [2.13311][2.13311:13383]()
    // the file for past
    // changes
    [2.13311]
    [2.13383]
    // the file for past changes