From 746fe067c4c693ac4c25c0dbcf49e1747bea0e17 Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Mon, 2 Jan 2012 14:18:25 +0100 Subject: [PATCH] Delete and Flush tests --- cache_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cache_test.go b/cache_test.go index 15936a0..925c46a 100644 --- a/cache_test.go +++ b/cache_test.go @@ -374,3 +374,37 @@ func TestReplace(t *testing.T) { t.Error("Couldn't replace existing key foo") } } + +func TestDelete(t *testing.T) { + tc := New(0, 0) + tc.Set("foo", "bar", 0) + tc.Delete("foo") + x, found := tc.Get("foo") + if found { + t.Error("foo was found, but it should have been deleted") + } + if x != nil { + t.Error("x is not nil:", x) + } +} + +func TestFlush(t *testing.T) { + tc := New(0, 0) + tc.Set("foo", "bar", 0) + tc.Set("baz", "yes", 0) + tc.Flush() + x, found := tc.Get("foo") + if found { + t.Error("foo was found, but it should have been deleted") + } + if x != nil { + t.Error("x is not nil:", x) + } + x, found = tc.Get("baz") + if found { + t.Error("baz was found, but it should have been deleted") + } + if x != nil { + t.Error("x is not nil:", x) + } +}