...
1 package testhelpers
2
3 import (
4 "os"
5
6 "github.com/launchdarkly/go-sdk-common/v3/ldlogtest"
7 "github.com/launchdarkly/go-server-sdk/v6/internal/sharedtest"
8 "github.com/launchdarkly/go-server-sdk/v6/subsystems"
9 )
10
11
12
13 type Fallible interface {
14 Failed() bool
15 }
16
17
18
19 func WithMockLoggingContext(t Fallible, action func(subsystems.ClientContext)) {
20 mockLog := ldlogtest.NewMockLog()
21 context := sharedtest.NewTestContext("", nil,
22 &subsystems.LoggingConfiguration{Loggers: mockLog.Loggers})
23 defer func() {
24 if t.Failed() {
25 mockLog.Dump(os.Stdout)
26 }
27
28
29 }()
30 action(context)
31 }
32
View as plain text