aboutsummaryrefslogtreecommitdiff
path: root/decaymap/decaymap_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'decaymap/decaymap_test.go')
-rw-r--r--decaymap/decaymap_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/decaymap/decaymap_test.go b/decaymap/decaymap_test.go
new file mode 100644
index 0000000..c930e08
--- /dev/null
+++ b/decaymap/decaymap_test.go
@@ -0,0 +1,31 @@
+package decaymap
+
+import (
+ "testing"
+ "time"
+)
+
+func TestImpl(t *testing.T) {
+ dm := New[string, string]()
+
+ dm.Set("test", "hi", 5*time.Minute)
+
+ val, ok := dm.Get("test")
+ if !ok {
+ t.Error("somehow the test key was not set")
+ }
+
+ if val != "hi" {
+ t.Errorf("wanted value %q, got: %q", "hi", val)
+ }
+
+ ok = dm.expire("test")
+ if !ok {
+ t.Error("somehow could not force-expire the test key")
+ }
+
+ _, ok = dm.Get("test")
+ if ok {
+ t.Error("got value even though it was supposed to be expired")
+ }
+}