mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
26 lines
567 B
Go
26 lines
567 B
Go
package cache2go
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRCacheSetGet(t *testing.T) {
|
|
rc := NewResponseCache(5 * time.Second)
|
|
rc.Cache("test", &CacheItem{Value: "best"})
|
|
v, err := rc.Get("test")
|
|
if err != nil || v.Value.(string) != "best" {
|
|
t.Error("Error retriving response cache: ", v, err)
|
|
}
|
|
}
|
|
|
|
func TestRCacheExpire(t *testing.T) {
|
|
rc := NewResponseCache(1 * time.Microsecond)
|
|
rc.Cache("test", &CacheItem{Value: "best"})
|
|
time.Sleep(1 * time.Millisecond)
|
|
_, err := rc.Get("test")
|
|
if err == nil {
|
|
t.Error("Error expiring response cache: ", err)
|
|
}
|
|
}
|