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