summaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: 7eeac96e7e36c4ca5daaffd830d352e1a859f59f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! This library drives [`gfold`](https://github.com/nickgerace/gfold), a CLI tool to help keep track of your Git repositories.
pub mod driver;
mod driver_internal;
mod util;

#[cfg(test)]
mod tests {
    use super::*;
    use std::env;

    #[test]
    fn current_directory() {
        let current_dir = env::current_dir().expect("failed to get CWD");
        assert_ne!(
            driver::Driver::new(
                &current_dir,
                driver::Config {
                    enable_unpushed_check: false,
                    include_non_repos: false,
                    no_color: false,
                    shallow: false,
                    show_email: false,
                    skip_sort: false,
                }
            )
            .is_err(),
            true
        );
    }

    #[test]
    fn parent_directory() {
        let mut current_dir = env::current_dir().expect("failed to get CWD");
        current_dir.pop();
        assert_ne!(
            driver::Driver::new(
                &current_dir,
                driver::Config {
                    enable_unpushed_check: false,
                    include_non_repos: false,
                    no_color: false,
                    shallow: false,
                    show_email: false,
                    skip_sort: false,
                }
            )
            .is_err(),
            true
        );
    }

    #[test]
    fn parent_directory_all_options() {
        let mut current_dir = env::current_dir().expect("failed to get CWD");
        current_dir.pop();
        let mut count = 1;
        for include_non_repos in vec![true, false] {
            for no_color in vec![true, false] {
                for shallow in vec![true, false] {
                    for show_email in vec![true, false] {
                        for skip_sort in vec![true, false] {
                            println!("[test:{} / include_non_repos:{} / no_color:{} / shallow:{} / show_email:{} / skip_sort:{}]", count, include_non_repos, no_color, shallow, show_email, skip_sort);
                            assert_ne!(
                                driver::Driver::new(
                                    &current_dir,
                                    driver::Config {
                                        enable_unpushed_check: false,
                                        include_non_repos,
                                        no_color,
                                        shallow,
                                        show_email,
                                        skip_sort,
                                    }
                                )
                                .is_err(),
                                true
                            );
                            count += 1;
                        }
                    }
                }
            }
        }
    }
}