34 lines
622 B
Go
34 lines
622 B
Go
package redis
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/company/ai-ops/internal/config"
|
|
)
|
|
|
|
func TestInitAndCloseWithLocalRedis(t *testing.T) {
|
|
ports := []int{16379, 6379}
|
|
var lastErr error
|
|
for _, port := range ports {
|
|
lastErr = Init(config.RedisConfig{Host: "localhost", Port: port, DB: 0})
|
|
if lastErr == nil {
|
|
break
|
|
}
|
|
_ = Close()
|
|
Client = nil
|
|
}
|
|
if lastErr != nil {
|
|
t.Skipf("Redis integration server not available: %v", lastErr)
|
|
}
|
|
if Client == nil {
|
|
t.Fatal("client not initialized")
|
|
}
|
|
if err := Close(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
Client = nil
|
|
if err := Close(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|