mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
Audit: optional logger for sinks will log on errors when context is done (#27859)
* Added optional logger for sink nodes (supplied by backends) will log on errors when context is also done * changelog
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -423,3 +424,37 @@ func TestOptions_WithFileMode(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestOptions_WithLogger exercises WithLogger Option to ensure it performs as expected.
|
||||
func TestOptions_WithLogger(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := map[string]struct {
|
||||
value hclog.Logger
|
||||
isNilExpected bool
|
||||
}{
|
||||
"nil-pointer": {
|
||||
value: nil,
|
||||
isNilExpected: true,
|
||||
},
|
||||
"logger": {
|
||||
value: hclog.NewNullLogger(),
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
opts := &options{}
|
||||
applyOption := WithLogger(tc.value)
|
||||
err := applyOption(opts)
|
||||
require.NoError(t, err)
|
||||
if tc.isNilExpected {
|
||||
require.Nil(t, opts.withLogger)
|
||||
} else {
|
||||
require.NotNil(t, opts.withLogger)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user