summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go')
-rw-r--r--vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go b/vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
index bc9c77c20..326299de8 100644
--- a/vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
+++ b/vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
@@ -173,7 +173,7 @@ func TestRoot(t *testing.T) {
}
val, ok := r.Get(nil)
if !ok || val != true {
- t.Fatalf("bad: %v %#v", val)
+ t.Fatalf("bad: %#v", val)
}
r, val, ok = r.Delete(nil)
if !ok || val != true {
@@ -1494,3 +1494,38 @@ func TestTrackMutate_cachedNodeChange(t *testing.T) {
}
}
}
+
+func TestLenTxn(t *testing.T) {
+ r := New()
+
+ if r.Len() != 0 {
+ t.Fatalf("not starting with empty tree")
+ }
+
+ txn := r.Txn()
+ keys := []string{
+ "foo/bar/baz",
+ "foo/baz/bar",
+ "foo/zip/zap",
+ "foobar",
+ "nochange",
+ }
+ for _, k := range keys {
+ txn.Insert([]byte(k), nil)
+ }
+ r = txn.Commit()
+
+ if r.Len() != len(keys) {
+ t.Fatalf("bad: expected %d, got %d", len(keys), r.Len())
+ }
+
+ txn = r.Txn()
+ for _, k := range keys {
+ txn.Delete([]byte(k))
+ }
+ r = txn.Commit()
+
+ if r.Len() != 0 {
+ t.Fatalf("tree len should be zero, got %d", r.Len())
+ }
+}