cacheinterface/memory_test.go

39 lines
566 B
Go

package cache
import (
"testing"
"time"
)
func Test_MemoryURI(t *testing.T) {
cache, err := New("memory://")
if err != nil {
t.Fatal("Error creating cache:", err)
}
if _, ok := cache.(*MemoryCache); !ok {
t.Fatal("Cache is not instance of MemoryCache")
}
}
func Test_MemoryStoreGet(t *testing.T) {
cache, err := New("memory://")
if err != nil {
t.Fatal("Error creating cache:", err)
}
obj := "test"
cache.Set("test", obj, time.Minute)
var new string
cache.Get("test", &new)
if obj != new {
t.Fatal("Expected", obj, "got", new)
}
}