Skip to content

Commit

Permalink
Fixed validation bug when catalog is injected itself
Browse files Browse the repository at this point in the history
  • Loading branch information
zaychenko-sergei committed Sep 4, 2023
1 parent 75eb232 commit 61a4c91
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.2] - 2023-09-04
### Changed
- Fixed validation of Catalog self-injection

## [0.7.1] - 2023-08-30
### Changed
- Linked with latest dependencies
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = ["dill-impl", "dill"]


[workspace.package]
version = "0.7.1"
version = "0.7.2"
edition = "2021"
readme = "README.md"
homepage = "https://github.com/sergiimk/dill-rs"
Expand All @@ -17,4 +17,4 @@ include = ["benches/*.rs", "src/**/*.rs", "Cargo.toml"]


[workspace.dependencies]
dill-impl = { path = "dill-impl", version = "0.7.1" }
dill-impl = { path = "dill-impl", version = "0.7.2" }
4 changes: 4 additions & 0 deletions dill/src/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ impl DependencySpec for OneOf<Catalog> {
// TODO: Avoid wrapping in Arc?
Ok(Arc::new(cat.clone()))
}

fn check(_: &Catalog) -> Result<(), InjectionError> {
Ok(())
}
}

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down
24 changes: 24 additions & 0 deletions dill/tests/tests/test_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,27 @@ fn test_validate_ingores_bound_fields() {

b.validate().unwrap();
}

#[test]
fn test_validate_catalog_inject() {
trait A: Send + Sync {}

#[allow(dead_code)]
struct AImpl {
catalog: Catalog,
}

#[component]
impl AImpl {
pub fn new(catalog: Catalog) -> Self {
Self { catalog }
}
}
impl A for AImpl {}

let mut b = CatalogBuilder::new();
b.add::<AImpl>();
b.bind::<dyn A, AImpl>();

b.validate().unwrap();
}

0 comments on commit 61a4c91

Please sign in to comment.