diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-02-16 06:47:51 -0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-02-16 09:47:51 -0500 |
commit | 6d8f122a5160f6d9e4c51579f2429dfaa62c7271 (patch) | |
tree | 6e0242cd6709260abd74060a7ec7dc1381efa36e /vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go | |
parent | b112747de76f9c11c4d8083207049fac6e435019 (diff) | |
download | chat-6d8f122a5160f6d9e4c51579f2429dfaa62c7271.tar.gz chat-6d8f122a5160f6d9e4c51579f2429dfaa62c7271.tar.bz2 chat-6d8f122a5160f6d9e4c51579f2429dfaa62c7271.zip |
Upgrading server dependancies (#8308)
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.go | 37 |
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()) + } +} |