return EtcdErrorNodeExist when Create is called for existing node
This commit is contained in:
parent
d46bfcb132
commit
ccb7e8793b
@ -30,11 +30,13 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
EtcdErrorCodeNotFound = 100
|
EtcdErrorCodeNotFound = 100
|
||||||
|
EtcdErrorCodeNodeExist = 105
|
||||||
EtcdErrorCodeValueRequired = 200
|
EtcdErrorCodeValueRequired = 200
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
EtcdErrorNotFound = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNotFound}
|
EtcdErrorNotFound = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNotFound}
|
||||||
|
EtcdErrorNodeExist = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNodeExist}
|
||||||
EtcdErrorValueRequired = &etcd.EtcdError{ErrorCode: EtcdErrorCodeValueRequired}
|
EtcdErrorValueRequired = &etcd.EtcdError{ErrorCode: EtcdErrorCodeValueRequired}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -137,11 +137,16 @@ func (f *FakeEtcdClient) CompareAndSwap(key, value string, ttl uint64, prevValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeEtcdClient) Create(key, value string, ttl uint64) (*etcd.Response, error) {
|
func (f *FakeEtcdClient) Create(key, value string, ttl uint64) (*etcd.Response, error) {
|
||||||
|
if prevResult, ok := f.Data[key]; ok && prevResult.R != nil && prevResult.R.Node != nil {
|
||||||
|
return nil, EtcdErrorNodeExist
|
||||||
|
}
|
||||||
|
|
||||||
return f.Set(key, value, ttl)
|
return f.Set(key, value, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeEtcdClient) Delete(key string, recursive bool) (*etcd.Response, error) {
|
func (f *FakeEtcdClient) Delete(key string, recursive bool) (*etcd.Response, error) {
|
||||||
if f.Err != nil {
|
if f.Err != nil {
|
||||||
return f.Err
|
return nil, f.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Data[key] = EtcdResponseWithError{
|
f.Data[key] = EtcdResponseWithError{
|
||||||
|
Loading…
Reference in New Issue
Block a user