Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'http/cache_test.go')
-rw-r--r--http/cache_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/http/cache_test.go b/http/cache_test.go
index 1020750..2c6d4ea 100644
--- a/http/cache_test.go
+++ b/http/cache_test.go
@@ -39,3 +39,18 @@ func TestCacheCapacity(t *testing.T) {
}
}
}
+
+func TestCacheDuplicate(t *testing.T) {
+ c := NewCache(10)
+ ip := net.ParseIP("192.0.2.1")
+ response := Response{IP: ip}
+ c.Set(ip, response)
+ c.Set(ip, response)
+ want := 1
+ if got := len(c.entries); got != want {
+ t.Errorf("want %d entries, got %d", want, got)
+ }
+ if got := c.values.Len(); got != want {
+ t.Errorf("want %d values, got %d", want, got)
+ }
+}