mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-06-06 23:46:28 +02:00
36 lines
830 B
Go
36 lines
830 B
Go
|
package redis_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"log"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/go-redis/redis/v9"
|
||
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger"
|
||
|
. "github.com/onsi/ginkgo"
|
||
|
. "github.com/onsi/gomega"
|
||
|
)
|
||
|
|
||
|
// wrappedRedisLogger wraps a logger so that we can coerce the logger to
|
||
|
// fit the expected signature for go-redis logging
|
||
|
type wrappedRedisLogger struct {
|
||
|
*log.Logger
|
||
|
}
|
||
|
|
||
|
func (l *wrappedRedisLogger) Printf(_ context.Context, format string, v ...interface{}) {
|
||
|
l.Logger.Printf(format, v...)
|
||
|
}
|
||
|
|
||
|
func TestRedis(t *testing.T) {
|
||
|
logger.SetOutput(GinkgoWriter)
|
||
|
logger.SetErrOutput(GinkgoWriter)
|
||
|
|
||
|
redisLogger := &wrappedRedisLogger{Logger: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile)}
|
||
|
redisLogger.SetOutput(GinkgoWriter)
|
||
|
redis.SetLogger(redisLogger)
|
||
|
|
||
|
RegisterFailHandler(Fail)
|
||
|
RunSpecs(t, "Redis")
|
||
|
}
|