cacheinterface/memcache_test.go

36 lines
629 B
Go
Raw Normal View History

package cache
import (
"testing"
)
func Test_MemcacheURI(t *testing.T) {
cache, err := New("memcache://localhost")
if err != nil {
t.Fatal("Error creating cache:", err)
}
if _, ok := cache.(*MemcacheCache); !ok {
t.Fatal("Cache is not instance of MemcacheCache")
}
}
func Test_MemcacheURIMultipleServers(t *testing.T) {
cache, err := New("memcache://localhost,localhost2")
if err != nil {
t.Fatal("Error creating cache:", err)
}
c, ok := cache.(*MemcacheCache)
if !ok {
t.Fatal("Cache is not instance of MemcacheCache")
}
if len(c.servers) != 2 {
t.Fatal("Number of servers does not match!")
}
}