xecute 0.1.2

Nest-style modules and dependency injection for Axum
Documentation
//! Verify macro-generated factories and module registrations together.

use std::sync::Arc;

use xecute::{Container, ModuleGraph};

#[xecute::injectable]
struct Repository {}

#[xecute::injectable]
struct Service {
    repository: Arc<Repository>,
    optional: Option<Arc<MissingOptional>>,
}

#[xecute::injectable]
struct MissingOptional {}

#[xecute::module(
    imports = [],
    providers = [Repository, Service],
    controllers = [],
    exports = [Service],
)]
struct TestModule;

#[test]
fn macros_generate_resolvable_provider_and_module_metadata() {
    let container = Container::builder()
        .injectable::<Repository>()
        .injectable::<Service>()
        .build()
        .unwrap();
    let service = container.resolve::<Service>().unwrap();
    assert!(Arc::strong_count(&service.repository) >= 1);
    assert!(service.optional.is_none());

    let graph = ModuleGraph::new(vec![TestModule::definition()]);
    assert!(graph.build().is_ok());
}