Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container and Resolver interfaces. Resolver can resolve against multiple containers. #2

Merged
merged 5 commits into from Oct 14, 2021

Conversation

HnH
Copy link
Owner

@HnH HnH commented Oct 14, 2021

func (suite *ResolverSuite) TestResolveMultiContainer() {
	var (
		localContainer   = di.NewContainer()
		localResolver, _ = di.NewResolver(localContainer, suite.container)
	)

	suite.Require().NoError(suite.container.Singleton(newRectangle))
	suite.Require().NoError(localContainer.Singleton(newMySQL))

	var s Shape
	suite.Require().NoError(suite.resolver.Resolve(&s))
	suite.Require().IsType(&Rectangle{}, s)

	var db Database
	suite.Require().EqualError(suite.resolver.Resolve(&db), "di: no binding found for: di_test.Database")
	suite.Require().Nil(db)

	suite.Require().NoError(localResolver.Resolve(&db))
	suite.Require().IsType(&MySQL{}, db)
}

@HnH HnH merged commit cdcf1cf into master Oct 14, 2021
@HnH HnH deleted the multi-container branch October 14, 2021 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant