elif_http/testing/
container.rs1use elif_core::container::IocContainer;
4use std::sync::Arc;
5
6pub 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
13pub 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
20pub 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}