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:
parent
f0d98a69ef
commit
1ee6740688
1 changed files with 42 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue