Implement namespace optional arg

This commit is contained in:
Bel LaPointe
2019-03-20 09:54:26 -06:00
parent b79cb97ba6
commit b7a231feaf
10 changed files with 101 additions and 45 deletions

View File

@@ -15,16 +15,18 @@ type mock struct {
m map[string][]byte
}
func (mock *mock) Get(key string) ([]byte, error) {
v, ok := mock.m[key]
func (mock *mock) Get(key string, ns ...string) ([]byte, error) {
namespace := resolveNamespace(ns)
v, ok := mock.m[path.Join(namespace, key)]
if ok {
return v, nil
}
return nil, ErrNotFound
}
func (mock *mock) Set(key string, value []byte) error {
mock.m[key] = value
func (mock *mock) Set(key string, value []byte, ns ...string) error {
namespace := resolveNamespace(ns)
mock.m[path.Join(namespace, key)] = value
return nil
}
@@ -118,6 +120,12 @@ func TestImplementations(t *testing.T) {
cases = append(cases, memcacheCluster)
}
if minio, err := NewMinio("localhost:9000", "accesskey", "secretkey"); err != nil {
t.Errorf("cannot make minio: %v", err)
} else {
cases = append(cases, minio)
}
validKey := "key"
validValue := []byte("value")