diff options
Diffstat (limited to 'service/container_test.go')
-rw-r--r-- | service/container_test.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/service/container_test.go b/service/container_test.go index 33ad9491..5350de41 100644 --- a/service/container_test.go +++ b/service/container_test.go @@ -132,6 +132,20 @@ func TestContainer_Has(t *testing.T) { assert.False(t, c.Has("another")) } +func TestContainer_List(t *testing.T) { + logger, hook := test.NewNullLogger() + logger.SetLevel(logrus.DebugLevel) + + c := NewContainer(logger) + c.Register("test", &testService{}) + + assert.Equal(t, 0, len(hook.Entries)) + assert.Equal(t, 1, len(c.List())) + + assert.True(t, c.Has("test")) + assert.False(t, c.Has("another")) +} + func TestContainer_Get(t *testing.T) { logger, hook := test.NewNullLogger() logger.SetLevel(logrus.DebugLevel) @@ -428,6 +442,10 @@ func TestContainer_InitErrorB(t *testing.T) { type testInitC struct{} +func (r *testInitC) Test() bool { + return true +} + func TestContainer_NoInit(t *testing.T) { logger, _ := test.NewNullLogger() logger.SetLevel(logrus.DebugLevel) @@ -449,7 +467,6 @@ func (c *DCfg) Hydrate(cfg Config) error { if err := cfg.Unmarshal(c); err != nil { return err } - if c.V == "fail" { return errors.New("failed config") } |