Files
grafana/pkg/plugins/log/fake.go
Will Browne 12dc56ad0c Plugins: Refactor plugin repository API (#69063)
* support grafana wildcard version

* undo go.mod changes

* tidy

* flesh out tests

* refactor

* add tests

* tidy naming

* undo some changes

* split interfaces

* separation

* update new signature

* simplify

* update var namings

* unexport types

* introduce opts pattern

* reorder test

* fix compat checks

* middle ground

* unexport client

* move back

* fix tests

* inline logger

* make client usable

* use fake logger

* tidy errors

* remove unused types

* fix test

* review fixes

* rework compatibility

* adjust installer

* fix tests

* opts => cfg

* remove unused var

* fix var name
2023-05-30 11:48:52 +02:00

68 lines
1.7 KiB
Go

package log
var _ Logger = (*TestLogger)(nil)
type TestLogger struct {
DebugLogs Logs
InfoLogs Logs
WarnLogs Logs
ErrorLogs Logs
}
func NewTestLogger() *TestLogger {
return &TestLogger{}
}
func (f *TestLogger) New(_ ...interface{}) Logger {
return NewTestLogger()
}
func (f *TestLogger) Info(msg string, ctx ...interface{}) {
f.InfoLogs.Calls++
f.InfoLogs.Message = msg
f.InfoLogs.Ctx = ctx
}
func (f *TestLogger) Warn(msg string, ctx ...interface{}) {
f.WarnLogs.Calls++
f.WarnLogs.Message = msg
f.WarnLogs.Ctx = ctx
}
func (f *TestLogger) Debug(msg string, ctx ...interface{}) {
f.DebugLogs.Calls++
f.DebugLogs.Message = msg
f.DebugLogs.Ctx = ctx
}
func (f *TestLogger) Error(msg string, ctx ...interface{}) {
f.ErrorLogs.Calls++
f.ErrorLogs.Message = msg
f.ErrorLogs.Ctx = ctx
}
type Logs struct {
Calls int
Message string
Ctx []interface{}
}
var _ PrettyLogger = (*TestPrettyLogger)(nil)
type TestPrettyLogger struct{}
func NewTestPrettyLogger() *TestPrettyLogger {
return &TestPrettyLogger{}
}
func (f *TestPrettyLogger) Successf(_ string, _ ...interface{}) {}
func (f *TestPrettyLogger) Failuref(_ string, _ ...interface{}) {}
func (f *TestPrettyLogger) Info(_ ...interface{}) {}
func (f *TestPrettyLogger) Infof(_ string, _ ...interface{}) {}
func (f *TestPrettyLogger) Debug(_ ...interface{}) {}
func (f *TestPrettyLogger) Debugf(_ string, _ ...interface{}) {}
func (f *TestPrettyLogger) Warn(_ ...interface{}) {}
func (f *TestPrettyLogger) Warnf(_ string, _ ...interface{}) {}
func (f *TestPrettyLogger) Error(_ ...interface{}) {}
func (f *TestPrettyLogger) Errorf(_ string, _ ...interface{}) {}