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

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomasi committed Sep 6, 2021
1 parent 8d58567 commit 79a4a6c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ func TestContainer_FindByTag(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, instances, 1)
assert.IsType(t, &TestService2{}, instances[0]) // nolint:exhaustivestruct


container.Register(di.NewServiceDef(di.StringRef("no-provider")).AddTag(di.StringRef("test")))
_, err = container.FindByTag(di.StringRef("test"))
assert.Error(t, err)
}

func TestContainer_GetEventBus(t *testing.T) {
Expand All @@ -222,3 +227,20 @@ func TestContainer_GetEventBus(t *testing.T) {
eb := container.GetEventBus()
assert.IsType(t, &eventbus.EventBus{}, eb)
}

func TestContainer_Get(t *testing.T) {
container, err := BuildContainer()
if err != nil {
t.Error(err)
}

_, err = container.Get(di.StringRef("TestService1"))
assert.NoError(t, err)

_, err = container.Get(di.StringRef("not-exiting"))
assert.Error(t, err)

container.Register(di.NewServiceDef(di.StringRef("no-provider")))
_, err = container.Get(di.StringRef("no-provider"))
assert.Error(t, err)
}

0 comments on commit 79a4a6c

Please # to comment.