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 { type Mock struct {
mock.Mock mock.Mock
endpoints []string // Endpoints passed to InitializeMock
options *Config Endpoints []string
// Options passed to InitializeMock
Options *Config
} }
// InitializeMock creates a Mock store. // InitializeMock creates a Mock store.
func InitializeMock(endpoints []string, options *Config) (Store, error) { func InitializeMock(endpoints []string, options *Config) (Store, error) {
s := &Mock{} s := &Mock{}
s.endpoints = endpoints s.Endpoints = endpoints
s.options = options s.Options = options
return s, nil return s, nil
} }

View File

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

View File

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