refactor create do not need to check existence first

This commit is contained in:
Xiang Li
2013-10-12 21:48:29 -07:00
parent 40c520ca1b
commit b0793e2dd9
2 changed files with 32 additions and 25 deletions

View File

@ -21,6 +21,17 @@ func TestCreateAndGet(t *testing.T) {
s.Delete("/foobar", true, 1, 1)
s.Create("/foobar/foo", "bar", false, false, Permanent, 1, 1)
// already exist, create should fail
_, err = s.Create("/foobar", "bar", false, false, Permanent, 1, 1)
if err == nil {
t.Fatal("Create should fail")
}
s.Delete("/foobar", true, 1, 1)
// this should create successfully
createAndGet(s, "/foobar", t)
createAndGet(s, "/foo/bar", t)
@ -365,7 +376,7 @@ func TestWatch(t *testing.T) {
c, _ = s.Watch("/foo", true, 0, 7, 1)
s.Delete("/foo/foo/boo", false, 8, 1)
e = nonblockingRetrive(c)
if e.Key != "/foo/foo/boo" || e.Action != Delete {
if e == nil || e.Key != "/foo/foo/boo" || e.Action != Delete {
t.Fatal("watch for Delete subdirectory fails")
}