aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/package/version/version_guesser_test.rs
blob: 1ec0ed40ba2e49be813b118808fae43d5b89c93b (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! ref: composer/tests/Composer/Test/Package/Version/VersionGuesserTest.php

use std::cell::RefCell;
use std::rc::Rc;

use shirabe::config::Config;
use shirabe::package::version::{VersionGuesser, VersionParser};
use shirabe::util::platform::Platform;
use shirabe::util::process_executor::ProcessExecutor;

#[allow(dead_code)]
fn set_up() {
    // Resets GitUtil's cached `version` static via ReflectionProperty; the static is not
    // exposed here and reflection-based mutation has no ported equivalent.
    todo!()
}

#[allow(dead_code)]
fn tear_down() {
    todo!()
}

#[allow(dead_code)]
struct TearDown;

impl Drop for TearDown {
    fn drop(&mut self) {
        tear_down();
    }
}

// These drive VersionGuesser with a mocked ProcessExecutor feeding git/hg command output;
// mocking is not available here.
#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_hg_guess_version_returns_data() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_guess_version_returns_data() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_guess_version_does_not_see_custom_default_branch_as_non_feature_branch() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming_regex()
 {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_guess_version_reads_and_respects_non_feature_branches_configuration_for_arbitrary_naming_when_on_non_feature_branch()
 {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_detached_head_becomes_dev_hash() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_detached_fetch_head_becomes_dev_hash_git2() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_detached_commit_head_becomes_dev_hash_git2() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_tag_becomes_version() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_tag_becomes_pretty_version() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_invalid_tag_becomes_version() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_numeric_branches_show_nicely() {
    todo!()
}

#[ignore = "requires getProcessExecutorMock with expects() command expectations; no ProcessExecutorMock mocking infrastructure exists"]
#[test]
fn test_remote_branches_are_selected() {
    todo!()
}

#[test]
fn test_get_root_version_from_env() {
    // @dataProvider rootEnvVersionsProvider
    let root_env_versions: Vec<(&str, &str)> = vec![
        ("1.0-dev", "1.0.x-dev"),
        ("1.0.x-dev", "1.0.x-dev"),
        ("1-dev", "1.x-dev"),
        ("1.x-dev", "1.x-dev"),
        ("1.0.0", "1.0.0"),
    ];

    for (env, expected_version) in root_env_versions {
        Platform::put_env("COMPOSER_ROOT_VERSION", env);
        let config = Rc::new(RefCell::new(Config::new(true, None)));
        let process = Rc::new(RefCell::new(ProcessExecutor::new(None)));
        let guesser = VersionGuesser::new(config, process, VersionParser::new(), None);
        assert_eq!(
            expected_version,
            guesser.get_root_version_from_env().unwrap()
        );
        Platform::clear_env("COMPOSER_ROOT_VERSION");
    }
}