index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat (limited to 'src/main.rs')

-rw-r--r-- src/main.rs 24
 1 file changed, 24 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index dea7035..ef61bfd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -79,3 +79,27 @@
    println!("Installed /etc/systemd/system/git-rs.service");
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::path::Path;
    use std::time::Instant;

    #[test]
    fn commit_list_populates_head_and_branch_tips_without_n_plus_one() {
        let repo = Repository::open(Path::new(env!("CARGO_MANIFEST_DIR"))).unwrap();
        let current_ref = Ref {
            name: repo.head_branch_name().unwrap(),
            is_head: true,
        };
        let gix_repo = repo.gix();

        let start = Instant::now();
        let (commits, _) = repo.commits(&gix_repo, &current_ref, 0, 50, None).unwrap();
        assert!(!commits.is_empty());
        assert!(commits[0].is_head(&repo).unwrap());
        assert!(!commits[0].branch_tips(&repo).unwrap().is_empty());
        assert!(start.elapsed().as_millis() < 100);
    }
}