Skip to content

Commit eaa0acc

Browse files
committed
refactor: [#114] rename tests to follow it_should_ convention
- Updated all 22 test names from test_* to it_should_* format - Aligns with project testing conventions in docs/contributing/testing/unit-testing.md - All tests pass (24 total: 22 unit + 2 doc tests) - All linters pass
1 parent 91d2eb3 commit eaa0acc

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

packages/dependency-installer/tests/detector_tests.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ use torrust_dependency_installer::{
1515
// =============================================================================
1616

1717
#[test]
18-
fn test_cargo_machete_detector_name() {
18+
fn it_should_return_cargo_machete_detector_name() {
1919
let detector = CargoMacheteDetector;
2020
assert_eq!(detector.name(), "cargo-machete");
2121
}
2222

2323
#[test]
24-
fn test_opentofu_detector_name() {
24+
fn it_should_return_opentofu_detector_name() {
2525
let detector = OpenTofuDetector;
2626
assert_eq!(detector.name(), "OpenTofu");
2727
}
2828

2929
#[test]
30-
fn test_ansible_detector_name() {
30+
fn it_should_return_ansible_detector_name() {
3131
let detector = AnsibleDetector;
3232
assert_eq!(detector.name(), "Ansible");
3333
}
3434

3535
#[test]
36-
fn test_lxd_detector_name() {
36+
fn it_should_return_lxd_detector_name() {
3737
let detector = LxdDetector;
3838
assert_eq!(detector.name(), "LXD");
3939
}
@@ -47,31 +47,31 @@ fn test_lxd_detector_name() {
4747
// that the detection logic executes successfully without panicking.
4848

4949
#[test]
50-
fn test_cargo_machete_detector_runs_without_error() {
50+
fn it_should_run_cargo_machete_detector_without_error() {
5151
let detector = CargoMacheteDetector;
5252
// Should not panic - result depends on system state
5353
let result = detector.is_installed();
5454
assert!(result.is_ok(), "Detection should not error");
5555
}
5656

5757
#[test]
58-
fn test_opentofu_detector_runs_without_error() {
58+
fn it_should_run_opentofu_detector_without_error() {
5959
let detector = OpenTofuDetector;
6060
// Should not panic - result depends on system state
6161
let result = detector.is_installed();
6262
assert!(result.is_ok(), "Detection should not error");
6363
}
6464

6565
#[test]
66-
fn test_ansible_detector_runs_without_error() {
66+
fn it_should_run_ansible_detector_without_error() {
6767
let detector = AnsibleDetector;
6868
// Should not panic - result depends on system state
6969
let result = detector.is_installed();
7070
assert!(result.is_ok(), "Detection should not error");
7171
}
7272

7373
#[test]
74-
fn test_lxd_detector_runs_without_error() {
74+
fn it_should_run_lxd_detector_without_error() {
7575
let detector = LxdDetector;
7676
// Should not panic - result depends on system state
7777
let result = detector.is_installed();
@@ -83,7 +83,7 @@ fn test_lxd_detector_runs_without_error() {
8383
// =============================================================================
8484

8585
#[test]
86-
fn test_detectors_have_no_required_version_by_default() {
86+
fn it_should_return_no_required_version_by_default_for_all_detectors() {
8787
let cargo_machete = CargoMacheteDetector;
8888
let opentofu = OpenTofuDetector;
8989
let ansible = AnsibleDetector;
@@ -100,21 +100,21 @@ fn test_detectors_have_no_required_version_by_default() {
100100
// =============================================================================
101101

102102
#[test]
103-
fn test_dependency_manager_creation() {
103+
fn it_should_create_dependency_manager() {
104104
let manager = DependencyManager::new();
105105
// Should not panic
106106
drop(manager);
107107
}
108108

109109
#[test]
110-
fn test_dependency_manager_default() {
110+
fn it_should_create_dependency_manager_with_default() {
111111
let manager = DependencyManager::default();
112112
// Should not panic
113113
drop(manager);
114114
}
115115

116116
#[test]
117-
fn test_dependency_manager_check_all_runs() {
117+
fn it_should_check_all_dependencies_without_error() {
118118
let manager = DependencyManager::new();
119119
let results = manager.check_all();
120120

@@ -134,28 +134,28 @@ fn test_dependency_manager_check_all_runs() {
134134
}
135135

136136
#[test]
137-
fn test_dependency_manager_get_detector_cargo_machete() {
137+
fn it_should_get_cargo_machete_detector_from_manager() {
138138
let manager = DependencyManager::new();
139139
let detector = manager.get_detector(Dependency::CargoMachete);
140140
assert_eq!(detector.name(), "cargo-machete");
141141
}
142142

143143
#[test]
144-
fn test_dependency_manager_get_detector_opentofu() {
144+
fn it_should_get_opentofu_detector_from_manager() {
145145
let manager = DependencyManager::new();
146146
let detector = manager.get_detector(Dependency::OpenTofu);
147147
assert_eq!(detector.name(), "OpenTofu");
148148
}
149149

150150
#[test]
151-
fn test_dependency_manager_get_detector_ansible() {
151+
fn it_should_get_ansible_detector_from_manager() {
152152
let manager = DependencyManager::new();
153153
let detector = manager.get_detector(Dependency::Ansible);
154154
assert_eq!(detector.name(), "Ansible");
155155
}
156156

157157
#[test]
158-
fn test_dependency_manager_get_detector_lxd() {
158+
fn it_should_get_lxd_detector_from_manager() {
159159
let manager = DependencyManager::new();
160160
let detector = manager.get_detector(Dependency::Lxd);
161161
assert_eq!(detector.name(), "LXD");
@@ -166,7 +166,7 @@ fn test_dependency_manager_get_detector_lxd() {
166166
// =============================================================================
167167

168168
#[test]
169-
fn test_check_result_creation() {
169+
fn it_should_create_check_result() {
170170
let result = CheckResult {
171171
tool: "test-tool".to_string(),
172172
installed: true,
@@ -177,7 +177,7 @@ fn test_check_result_creation() {
177177
}
178178

179179
#[test]
180-
fn test_check_result_clone() {
180+
fn it_should_clone_check_result() {
181181
let result = CheckResult {
182182
tool: "test-tool".to_string(),
183183
installed: false,
@@ -193,7 +193,7 @@ fn test_check_result_clone() {
193193
// =============================================================================
194194

195195
#[test]
196-
fn test_command_exists_for_known_command() {
196+
fn it_should_detect_existing_command() {
197197
use torrust_dependency_installer::command::command_exists;
198198

199199
// Test with 'sh' which should always exist on Unix systems
@@ -204,7 +204,7 @@ fn test_command_exists_for_known_command() {
204204
}
205205

206206
#[test]
207-
fn test_command_exists_for_nonexistent_command() {
207+
fn it_should_detect_nonexistent_command() {
208208
use torrust_dependency_installer::command::command_exists;
209209

210210
// Test with a command that definitely doesn't exist
@@ -215,7 +215,7 @@ fn test_command_exists_for_nonexistent_command() {
215215
}
216216

217217
#[test]
218-
fn test_execute_command_success() {
218+
fn it_should_execute_command_successfully() {
219219
use torrust_dependency_installer::command::execute_command;
220220

221221
// Test with 'echo' which should always work
@@ -225,7 +225,7 @@ fn test_execute_command_success() {
225225
}
226226

227227
#[test]
228-
fn test_execute_command_nonexistent() {
228+
fn it_should_fail_to_execute_nonexistent_command() {
229229
use torrust_dependency_installer::command::execute_command;
230230

231231
// Test with nonexistent command

0 commit comments

Comments
 (0)