Browse Source

more testandset test cases

Xiang Li 12 years ago
parent
commit
6d27afd1c9
1 changed files with 9 additions and 0 deletions
  1. 9 0
      file_system/file_system_test.go

+ 9 - 0
file_system/file_system_test.go

@@ -189,6 +189,15 @@ func TestTestAndSet(t *testing.T) {
 		t.Fatalf("[%v/%v] [%v/%v]", e.PrevValue, "car", e.Value, "bar")
 		t.Fatalf("[%v/%v] [%v/%v]", e.PrevValue, "car", e.Value, "bar")
 	}
 	}
 
 
+	// test on empty previous value
+	e, err = fs.TestAndSet("/fooDir/foo", "", 0, "bar", Permanent, 4, 1)
+	if err != nil {
+		t.Fatal("test on empty node should be succeeded")
+	}
+
+	if e.Key != "/fooDir/foo" || e.PrevValue != "" || e.Value != "bar" {
+		t.Fatalf("[%v/%v] [%v/%v] [%v/%v]", e.Key, "/fooDir/foo", e.PrevValue, "", e.Value, "bar")
+	}
 }
 }
 
 
 func setAndGet(fs *FileSystem, path string, t *testing.T) {
 func setAndGet(fs *FileSystem, path string, t *testing.T) {