2015-03-30 18:55:03 +02:00
|
|
|
package authboss
|
|
|
|
|
|
|
|
import (
|
2018-02-02 22:11:47 +02:00
|
|
|
"context"
|
2015-03-30 18:55:03 +02:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2018-02-02 22:11:47 +02:00
|
|
|
type (
|
|
|
|
testLogger struct{}
|
|
|
|
testCtxLogger struct{}
|
|
|
|
)
|
2015-03-31 21:34:03 +02:00
|
|
|
|
2018-02-02 22:11:47 +02:00
|
|
|
func (t testLogger) Info(string) {}
|
|
|
|
func (t testLogger) Error(string) {}
|
|
|
|
|
|
|
|
func (t testLogger) FromContext(ctx context.Context) Logger { return testCtxLogger{} }
|
2015-03-30 18:55:03 +02:00
|
|
|
|
2018-02-02 22:11:47 +02:00
|
|
|
func (t testCtxLogger) Info(string) {}
|
|
|
|
func (t testCtxLogger) Error(string) {}
|
|
|
|
|
|
|
|
func TestLogger(t *testing.T) {
|
2015-03-31 21:34:03 +02:00
|
|
|
t.Parallel()
|
|
|
|
|
2018-02-02 22:11:47 +02:00
|
|
|
ab := New()
|
|
|
|
logger := testLogger{}
|
|
|
|
ab.Config.Core.Logger = logger
|
|
|
|
|
|
|
|
if logger != ab.Logger(nil).(testLogger) {
|
|
|
|
t.Error("wanted our logger back")
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := ab.Logger(context.Background()).(testCtxLogger); !ok {
|
|
|
|
t.Error("wanted ctx logger back")
|
2015-03-30 18:55:03 +02:00
|
|
|
}
|
|
|
|
}
|