Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
test: add test for find by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomasi committed Sep 2, 2021
1 parent f69cc37 commit da7363c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit da7363c

Please # to comment.