1
0
Fork 0
mirror of https://github.com/alice-lg/birdwatcher.git synced 2025-03-09 00:00:05 +01:00

improved caching tests

This commit is contained in:
Matthias Hannig 2019-01-24 19:01:05 +01:00
parent f0d98a69ef
commit 1ee6740688

View file

@ -56,3 +56,45 @@ func Test_RedisCacheAccessKeyMissing(t *testing.T) {
t.Log("Cache error:", err)
t.Log(parsed)
}
func Test_RedisCacheRoutes(t *testing.T) {
f, err := openFile("routes_bird1_ipv4.sample")
if err != nil {
t.Error(err)
}
defer f.Close()
parsed := parseRoutes(f)
_, ok := parsed["routes"].([]Parsed)
if !ok {
t.Fatal("Error getting routes")
}
cache, err := NewRedisCache(CacheConfig{
RedisServer: "localhost:6379",
})
if err != nil {
t.Log("Redis server not available:", err)
t.Log("Skipping redis tests.")
return
}
err = cache.Set("routes_protocol_test", parsed)
if err != nil {
t.Error(err)
}
parsed, err = cache.Get("routes_protocol_test")
if err != nil {
t.Error(err)
return
}
routes, ok := parsed["routes"].([]interface{})
if !ok {
t.Error("Error getting routes")
}
t.Log("Retrieved routes:", len(routes))
}