diff --git a/veinmind-common/go/service/conf/default_test.go b/veinmind-common/go/service/conf/default_test.go index d0909a86..1a920a4e 100644 --- a/veinmind-common/go/service/conf/default_test.go +++ b/veinmind-common/go/service/conf/default_test.go @@ -5,10 +5,23 @@ import ( "testing" ) -func TestDefaultClient(t *testing.T) { +func TestDefaultClient(t *testing.T) { c := DefaultConfClient() - _, err := c.Pull(Sensitive) + _, err := c.Pull(Sensitive) assert.Error(t, err) } +func TestNewConfService(t *testing.T) { + s, err := NewConfService() + if err != nil { + t.Error(err) + } + s.Store(Sensitive, []byte{0x01}) + b, err := s.Pull(Sensitive) + if err != nil { + t.Error(err) + } + + assert.Equal(t, b, []byte{0x01}) +} diff --git a/veinmind-common/go/service/conf/service.go b/veinmind-common/go/service/conf/service.go index eac28d94..91631c81 100644 --- a/veinmind-common/go/service/conf/service.go +++ b/veinmind-common/go/service/conf/service.go @@ -19,6 +19,12 @@ type confClient struct { Pull func(ns PluginConfNS) ([]byte, error) } +func NewConfService() (*ConfService, error) { + c := new(ConfService) + c.store = make(map[PluginConfNS][]byte) + return c, nil +} + func (c *ConfService) Pull(ns PluginConfNS) ([]byte, error) { if b, ok := c.store[ns]; ok { return b, nil