Skip to content

Commit

Permalink
Allow custom logger to be used in mock resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail committed May 22, 2024
1 parent d106975 commit 8534a88
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions public/service/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ func MockResources(opts ...MockResourcesOptFn) *Resources {
// MockResourcesOptFn provides a func based optional argument to MockResources.
type MockResourcesOptFn func(*mock.Manager)

// MockResourcesOptUseLogger sets the logger to be used by components
// referencing these resources.
func MockResourcesOptUseLogger(l *Logger) MockResourcesOptFn {
return func(m *mock.Manager) {
if l != nil {
m.L = l.m
}
}
}

// MockResourcesOptAddCache instantiates the resources type with a mock cache
// with a given name. Cached items are held in memory.
func MockResourcesOptAddCache(name string) MockResourcesOptFn {
Expand Down

0 comments on commit 8534a88

Please sign in to comment.