1
use super::*;
2

            
3
#[test]
4
1
fn full_hash_is_forty_hex_digits() -> io::Result<()> {
5
1
    let hash = commit_hash(false)?;
6
1
    assert_eq!(hash.len(), 40);
7
40
    assert!(hash.chars().all(|c| c.is_ascii_hexdigit()));
8
1
    Ok(())
9
1
}
10

            
11
#[test]
12
1
fn short_hash_prefixes_full_hash() -> io::Result<()> {
13
1
    assert!(commit_hash(false)?.starts_with(&commit_hash(true)?));
14
1
    Ok(())
15
1
}
16

            
17
#[test]
18
1
fn commit_date_is_rfc3339() -> io::Result<()> {
19
1
    let date = commit_date()?;
20
1
    assert_eq!(date.matches('T').count(), 1, "{date}");
21
1
    assert!(date.len() >= 20, "{date}");
22
1
    Ok(())
23
1
}
24

            
25
#[test]
26
1
fn head_files_are_existing_absolute_paths_including_head() -> io::Result<()> {
27
1
    let files = head_files()?;
28
1
    assert!(files.iter().any(|f| f.ends_with("HEAD")));
29
2
    assert!(files.iter().all(|f| f.starts_with('/')));
30
2
    assert!(files.iter().all(|f| Path::new(f).exists()), "{files:?}");
31
1
    Ok(())
32
1
}
33

            
34
#[test]
35
1
fn git_reports_failure_for_bad_arguments() {
36
1
    assert!(git(&["rev-parse", "--verify", "no-such-ref-xyz"]).is_err());
37
1
}