Skip to content

Commit 1964ea8

Browse files
committed
test: [#118] standardize dependency verification across E2E test files
Add verify_required_dependencies() calls to all E2E test functions in: - tests/e2e_create_command.rs (4 tests) - tests/e2e_destroy_command.rs (4 tests) All tests use empty dependency arrays with documentation explaining: - Current state: no system dependencies required - Future extensibility: how to add dependencies when needed This ensures consistency with the pattern established in E2E test binaries and facilitates future dependency additions.
1 parent 81496a3 commit 1964ea8

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

tests/e2e_create_command.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,41 @@
2222
2323
mod support;
2424

25+
use anyhow::Result;
2526
use support::{EnvironmentStateAssertions, ProcessRunner, TempWorkspace};
27+
use torrust_dependency_installer::{verify_dependencies, Dependency};
28+
29+
/// Verify that all required dependencies are installed for create command E2E tests.
30+
///
31+
/// **Current State**: No system dependencies required.
32+
///
33+
/// These black-box tests run the production binary as an external process and verify
34+
/// the create command workflow. Currently, they only test the command interface and
35+
/// environment persistence, without requiring infrastructure tools.
36+
///
37+
/// # Future Dependencies
38+
///
39+
/// If these tests evolve to verify actual infrastructure provisioning or configuration,
40+
/// add required dependencies here:
41+
/// ```ignore
42+
/// let required_deps = &[Dependency::OpenTofu, Dependency::Ansible, Dependency::Lxd];
43+
/// ```
44+
///
45+
/// # Errors
46+
///
47+
/// Returns an error if any required dependencies are missing or cannot be detected.
48+
fn verify_required_dependencies() -> Result<()> {
49+
// Currently no system dependencies required - empty array
50+
let required_deps: &[Dependency] = &[];
51+
verify_dependencies(required_deps)?;
52+
Ok(())
53+
}
2654

2755
#[test]
2856
fn it_should_create_environment_from_config_file_black_box() {
57+
// Verify dependencies before running tests
58+
verify_required_dependencies().expect("Dependency verification failed");
59+
2960
// Arrange: Create temporary workspace
3061
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
3162

@@ -59,6 +90,9 @@ fn it_should_create_environment_from_config_file_black_box() {
5990

6091
#[test]
6192
fn it_should_fail_gracefully_with_invalid_config() {
93+
// Verify dependencies before running tests
94+
verify_required_dependencies().expect("Dependency verification failed");
95+
6296
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
6397

6498
// Create invalid configuration (missing required fields)
@@ -89,6 +123,9 @@ fn it_should_fail_gracefully_with_invalid_config() {
89123

90124
#[test]
91125
fn it_should_fail_when_config_file_not_found() {
126+
// Verify dependencies before running tests
127+
verify_required_dependencies().expect("Dependency verification failed");
128+
92129
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
93130

94131
// Run command with non-existent config file
@@ -113,6 +150,9 @@ fn it_should_fail_when_config_file_not_found() {
113150

114151
#[test]
115152
fn it_should_fail_when_environment_already_exists() {
153+
// Verify dependencies before running tests
154+
verify_required_dependencies().expect("Dependency verification failed");
155+
116156
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
117157

118158
let config = create_test_environment_config("duplicate-env");

tests/e2e_destroy_command.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,35 @@
2020
2121
mod support;
2222

23+
use anyhow::Result;
2324
use support::{EnvironmentStateAssertions, ProcessRunner, TempWorkspace};
25+
use torrust_dependency_installer::{verify_dependencies, Dependency};
26+
27+
/// Verify that all required dependencies are installed for destroy command E2E tests.
28+
///
29+
/// **Current State**: No system dependencies required.
30+
///
31+
/// These black-box tests run the production binary as an external process and verify
32+
/// the destroy command workflow. Currently, they only test the command interface and
33+
/// environment state transitions, without requiring infrastructure tools.
34+
///
35+
/// # Future Dependencies
36+
///
37+
/// If these tests evolve to verify actual infrastructure destruction or cleanup,
38+
/// add required dependencies here:
39+
/// ```ignore
40+
/// let required_deps = &[Dependency::OpenTofu, Dependency::Ansible, Dependency::Lxd];
41+
/// ```
42+
///
43+
/// # Errors
44+
///
45+
/// Returns an error if any required dependencies are missing or cannot be detected.
46+
fn verify_required_dependencies() -> Result<()> {
47+
// Currently no system dependencies required - empty array
48+
let required_deps: &[Dependency] = &[];
49+
verify_dependencies(required_deps)?;
50+
Ok(())
51+
}
2452

2553
/// Helper function to create a test environment configuration
2654
fn create_test_environment_config(env_name: &str) -> String {
@@ -45,6 +73,9 @@ fn create_test_environment_config(env_name: &str) -> String {
4573

4674
#[test]
4775
fn it_should_destroy_environment_with_default_working_directory() {
76+
// Verify dependencies before running tests
77+
verify_required_dependencies().expect("Dependency verification failed");
78+
4879
// Arrange: Create temporary workspace
4980
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
5081

@@ -92,6 +123,9 @@ fn it_should_destroy_environment_with_default_working_directory() {
92123

93124
#[test]
94125
fn it_should_destroy_environment_with_custom_working_directory() {
126+
// Verify dependencies before running tests
127+
verify_required_dependencies().expect("Dependency verification failed");
128+
95129
// Arrange: Create temporary workspace
96130
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
97131

@@ -139,6 +173,9 @@ fn it_should_destroy_environment_with_custom_working_directory() {
139173

140174
#[test]
141175
fn it_should_fail_when_environment_not_found_in_working_directory() {
176+
// Verify dependencies before running tests
177+
verify_required_dependencies().expect("Dependency verification failed");
178+
142179
// Arrange: Create temporary workspace
143180
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
144181

@@ -164,6 +201,8 @@ fn it_should_fail_when_environment_not_found_in_working_directory() {
164201

165202
#[test]
166203
fn it_should_complete_full_lifecycle_with_custom_working_directory() {
204+
verify_required_dependencies().expect("Dependency verification failed");
205+
167206
// Arrange: Create temporary workspace
168207
let temp_workspace = TempWorkspace::new().expect("Failed to create temp workspace");
169208

0 commit comments

Comments
 (0)