1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-25 10:27:01 +08:00
Files
kubo/repo/mock.go
Jeromy ab0c668ab8 fix panic caused by accessing config after repo closed
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-09-03 09:28:36 -07:00

40 lines
840 B
Go

package repo
import (
"errors"
ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
"github.com/ipfs/go-ipfs/repo/config"
)
var errTODO = errors.New("TODO")
// Mock is not thread-safe
type Mock struct {
C config.Config
D ds.ThreadSafeDatastore
}
func (m *Mock) Config() (*config.Config, error) {
return &m.C, nil // FIXME threadsafety
}
func (m *Mock) SetConfig(updated *config.Config) error {
m.C = *updated // FIXME threadsafety
return nil
}
func (m *Mock) SetConfigKey(key string, value interface{}) error {
return errTODO
}
func (m *Mock) GetConfigKey(key string) (interface{}, error) {
return nil, errTODO
}
func (m *Mock) Datastore() ds.ThreadSafeDatastore { return m.D }
func (m *Mock) Close() error { return errTODO }
func (m *Mock) SetAPIAddr(addr string) error { return errTODO }