kubo/repo/mock.go
Jeromy cccc6a94a3 update go-multihash and bubble up changes
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2017-07-11 19:27:43 -07:00

54 lines
1.2 KiB
Go

package repo
import (
"errors"
filestore "github.com/ipfs/go-ipfs/filestore"
keystore "github.com/ipfs/go-ipfs/keystore"
"github.com/ipfs/go-ipfs/repo/config"
ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr"
)
var errTODO = errors.New("TODO: mock repo")
// Mock is not thread-safe
type Mock struct {
C config.Config
D Datastore
K keystore.Keystore
}
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() Datastore { return m.D }
func (m *Mock) GetStorageUsage() (uint64, error) { return 0, nil }
func (m *Mock) Close() error { return errTODO }
func (m *Mock) SetAPIAddr(addr ma.Multiaddr) error { return errTODO }
func (m *Mock) Keystore() keystore.Keystore { return nil }
func (m *Mock) SwarmKey() ([]byte, error) {
return nil, nil
}
func (m *Mock) FileManager() *filestore.FileManager { return nil }