@cryptotaxi247 / kubo / commits / c9a89458a

repo/mock: basic impl

Brian Tiger Chow committed Jan 14, 2015 at 18:55 UTC c9a89458a53c0abce4cbd8f03efccdf54eb1256f
1 file changed +37
repo/mock.go new
+37
@@ -0,0 +1,37 @@
1 +package repo
2 +
3 +import (
4 + "errors"
5 +
6 + ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 + "github.com/jbenet/go-ipfs/repo/config"
8 +)
9 +
10 +var errTODO = errors.New("TODO")
11 +
12 +// Mock is not thread-safe
13 +type Mock struct {
14 + C config.Config
15 + D ds.ThreadSafeDatastore
16 +}
17 +
18 +func (m *Mock) Config() *config.Config {
19 + return &m.C // FIXME threadsafety
20 +}
21 +
22 +func (m *Mock) SetConfig(updated *config.Config) error {
23 + m.C = *updated // FIXME threadsafety
24 + return nil
25 +}
26 +
27 +func (m *Mock) SetConfigKey(key string, value interface{}) error {
28 + return errTODO
29 +}
30 +
31 +func (m *Mock) GetConfigKey(key string) (interface{}, error) {
32 + return nil, errTODO
33 +}
34 +
35 +func (m *Mock) Datastore() ds.ThreadSafeDatastore { return m.D }
36 +
37 +func (m *Mock) Close() error { return errTODO }