store: Mock stores can now be created

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-05-16 17:45:56 -07:00
parent b459f7c7f8
commit f49ca7e20f
3 changed files with 10 additions and 6 deletions

View File

@ -6,15 +6,17 @@ import "github.com/stretchr/testify/mock"
type Mock struct {
mock.Mock
endpoints []string
options *Config
// Endpoints passed to InitializeMock
Endpoints []string
// Options passed to InitializeMock
Options *Config
}
// InitializeMock creates a Mock store.
func InitializeMock(endpoints []string, options *Config) (Store, error) {
s := &Mock{}
s.endpoints = endpoints
s.options = options
s.Endpoints = endpoints
s.Options = options
return s, nil
}

View File

@ -12,8 +12,10 @@ import (
type Backend string
const (
// MOCK backend
MOCK Backend = "mock"
// CONSUL backend
CONSUL Backend = "consul"
CONSUL = "consul"
// ETCD backend
ETCD = "etcd"
// ZK backend
@ -114,6 +116,7 @@ type Initialize func(addrs []string, options *Config) (Store, error)
var (
// Backend initializers
initializers = map[Backend]Initialize{
MOCK: InitializeMock,
CONSUL: InitializeConsul,
ETCD: InitializeEtcd,
ZK: InitializeZookeeper,

View File

@ -9,7 +9,6 @@ import (
)
// Zookeeper embeds the zookeeper client
// and list of watches
type Zookeeper struct {
timeout time.Duration
client *zk.Conn