From da7363ca842658a3e8bd792e2e589ba0093182ac Mon Sep 17 00:00:00 2001 From: Dominik Tomasi Date: Thu, 2 Sep 2021 12:59:23 +0200 Subject: [PATCH] test: add test for find by tag --- container_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/container_test.go b/container_test.go index f12fd95..ccf9bca 100644 --- a/container_test.go +++ b/container_test.go @@ -120,7 +120,8 @@ func BuildContainer() (*di.Container, error) { di.LoggerArg(), di.InterfaceArg(true), di.ParamArg("foo.bar.baz"), - ), + ). + AddTag(di.StringRef("test")), ) if err := container.Build(); err != nil { @@ -190,3 +191,15 @@ func TestContainer_Set(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &TestService1{}, instance) // nolint:exhaustivestruct } + +func TestContainer_FindByTag(t *testing.T) { + container, err := BuildContainer() + if err != nil { + t.Error(err) + } + + instances, err := container.FindByTag(di.StringRef("test")) + assert.NoError(t, err) + assert.Len(t, instances, 1) + assert.IsType(t, &TestService2{}, instances[0]) // nolint:exhaustivestruct +}