Skip to content

Commit 8a299fa

Browse files
committed
feat(veinmind-common): provide new func for conf service
1 parent 188a074 commit 8a299fa

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

veinmind-common/go/service/conf/default_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@ import (
55
"testing"
66
)
77

8-
func TestDefaultClient(t *testing.T) {
8+
func TestDefaultClient(t *testing.T) {
99
c := DefaultConfClient()
10-
_, err := c.Pull(Sensitive)
10+
_, err := c.Pull(Sensitive)
1111
assert.Error(t, err)
1212
}
1313

14+
func TestNewConfService(t *testing.T) {
15+
s, err := NewConfService()
16+
if err != nil {
17+
t.Error(err)
18+
}
1419

20+
s.Store(Sensitive, []byte{0x01})
21+
b, err := s.Pull(Sensitive)
22+
if err != nil {
23+
t.Error(err)
24+
}
25+
26+
assert.Equal(t, b, []byte{0x01})
27+
}

veinmind-common/go/service/conf/service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ type confClient struct {
1919
Pull func(ns PluginConfNS) ([]byte, error)
2020
}
2121

22+
func NewConfService() (*ConfService, error) {
23+
c := new(ConfService)
24+
c.store = make(map[PluginConfNS][]byte)
25+
return c, nil
26+
}
27+
2228
func (c *ConfService) Pull(ns PluginConfNS) ([]byte, error) {
2329
if b, ok := c.store[ns]; ok {
2430
return b, nil

0 commit comments

Comments
 (0)