chore: inline log.Interface and handle empty and nil slices the same
This commit is contained in:
@@ -31,7 +31,7 @@ import (
|
||||
// Mock has a Logger for use in unit-testing
|
||||
type Mock struct {
|
||||
*sync.RWMutex
|
||||
Logger log.Interface
|
||||
log.Interface
|
||||
Logged []string
|
||||
}
|
||||
|
||||
@@ -48,8 +48,9 @@ var _ log.Handler = &Mock{}
|
||||
// New instantiates a new Mock and sets the log.Handler to it
|
||||
func New() *Mock {
|
||||
mock := &Mock{
|
||||
RWMutex: &sync.RWMutex{},
|
||||
Logger: log.Log,
|
||||
RWMutex: &sync.RWMutex{},
|
||||
Interface: log.Log,
|
||||
Logged: make([]string, 0),
|
||||
}
|
||||
log.SetHandler(mock)
|
||||
return mock
|
||||
@@ -60,5 +61,8 @@ func (m *Mock) Check(t testing.TB, wantLogged []string) {
|
||||
t.Helper()
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
if wantLogged == nil {
|
||||
wantLogged = []string{}
|
||||
}
|
||||
assert.Equal(t, wantLogged, m.Logged)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user