elif_http/testing/
container.rs

1//! Test container setup utilities
2
3use elif_core::container::IocContainer;
4use std::sync::Arc;
5
6/// Create a test container with proper setup for HTTP tests
7pub fn create_test_container() -> Arc<IocContainer> {
8    let mut container = IocContainer::new();
9    container.build().expect("Test container build failed");
10    Arc::new(container)
11}
12
13/// Create a test container with additional services registered
14pub fn create_test_container_with_services() -> Arc<IocContainer> {
15    let mut container = IocContainer::new();
16    container.build().expect("Test container build failed");
17    Arc::new(container)
18}
19
20/// Test container builder for more complex test scenarios
21pub struct TestContainerBuilder {
22    container: IocContainer,
23}
24
25impl TestContainerBuilder {
26    pub fn new() -> Self {
27        Self {
28            container: IocContainer::new(),
29        }
30    }
31
32    pub fn build(mut self) -> Arc<IocContainer> {
33        self.container.build().expect("Test container build failed");
34        Arc::new(self.container)
35    }
36}
37
38impl Default for TestContainerBuilder {
39    fn default() -> Self {
40        Self::new()
41    }
42}