-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtests.rs
More file actions
45 lines (37 loc) · 1.53 KB
/
Copy pathtests.rs
File metadata and controls
45 lines (37 loc) · 1.53 KB
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
//! Test module for Release Command
//!
//! This module contains test infrastructure and test cases for the `ReleaseCommandHandler`.
use std::sync::Arc;
use chrono::Utc;
use tempfile::TempDir;
use super::handler::ReleaseCommandHandler;
use crate::domain::EnvironmentName;
use crate::infrastructure::persistence::filesystem::file_environment_repository::FileEnvironmentRepository;
use crate::testing::mock_clock::MockClock;
/// Helper to create a test handler with mock dependencies in a temp directory
fn create_test_handler() -> (ReleaseCommandHandler, TempDir) {
let temp_dir = TempDir::new().expect("Failed to create temp directory");
let clock = Arc::new(MockClock::new(Utc::now()));
let repository = Arc::new(FileEnvironmentRepository::new(
temp_dir.path().to_path_buf(),
));
let handler = ReleaseCommandHandler::new(repository, clock);
(handler, temp_dir)
}
#[test]
fn it_should_create_handler_with_dependencies() {
let (_handler, _temp_dir) = create_test_handler();
// Handler was created successfully - basic construction verified
}
#[tokio::test]
async fn it_should_return_environment_not_found_error_when_environment_does_not_exist() {
let (handler, _temp_dir) = create_test_handler();
let env_name = EnvironmentName::new("nonexistent-env").unwrap();
let result = handler.execute(&env_name, None).await;
assert!(result.is_err());
let error = result.unwrap_err();
assert!(
error.to_string().contains("not found"),
"Expected 'not found' error, got: {error}"
);
}