2022-04-29 13:02:25 -07:00
|
|
|
package cache_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-04-23 07:15:38 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/cache"
|
2022-04-29 13:02:25 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewCacheClient(t *testing.T) {
|
|
|
|
_ = cache.NewCacheClient("placeholder")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInsert(t *testing.T) {
|
|
|
|
cache := cache.NewCacheClient("Testing")
|
|
|
|
cache.Insert("UnitTesting", "Something, or nothing")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFindGroupMissing(t *testing.T) {
|
|
|
|
cache := cache.NewCacheClient("faker")
|
|
|
|
_, err := cache.FindByKey("UnitTesting")
|
2022-12-04 08:49:17 -08:00
|
|
|
if err == nil {
|
|
|
|
panic("Nothing was appended with the requested group.")
|
|
|
|
}
|
2022-04-29 13:02:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestFindGroupExists(t *testing.T) {
|
|
|
|
cache := cache.NewCacheClient("Testing")
|
|
|
|
cache.Insert("UnitTesting", "Something")
|
|
|
|
_, err := cache.FindByKey("UnitTesting")
|
2022-12-04 08:49:17 -08:00
|
|
|
if err != nil {
|
|
|
|
panic("")
|
|
|
|
}
|
2022-04-29 13:02:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCacheStorage(t *testing.T) {
|
|
|
|
cc := cache.NewCacheClient("Testing")
|
|
|
|
cc.Insert("UnitTesting01", "test")
|
|
|
|
cc.Insert("UnitTesting02", "Test")
|
|
|
|
|
|
|
|
cache := cache.NewCacheClient("Testing")
|
|
|
|
_, err := cache.FindByKey("UnitTesting02")
|
2022-12-04 08:49:17 -08:00
|
|
|
if err != nil {
|
|
|
|
panic("expected to find the value")
|
|
|
|
}
|
2022-04-29 13:02:25 -07:00
|
|
|
}
|