...
1 package mocks
2
3 import "github.com/launchdarkly/go-server-sdk/v6/subsystems"
4
5
6
7 type SingleComponentConfigurer[T any] struct {
8 Instance T
9 }
10
11 func (c SingleComponentConfigurer[T]) Build(clientContext subsystems.ClientContext) (T, error) {
12 return c.Instance, nil
13 }
14
15
16
17 type ComponentConfigurerThatReturnsError[T any] struct {
18 Err error
19 }
20
21 func (c ComponentConfigurerThatReturnsError[T]) Build(clientContext subsystems.ClientContext) (T, error) {
22 var empty T
23 return empty, c.Err
24 }
25
26
27
28 type ComponentConfigurerThatCapturesClientContext[T any] struct {
29 Configurer subsystems.ComponentConfigurer[T]
30 ReceivedClientContext subsystems.ClientContext
31 }
32
33 func (c *ComponentConfigurerThatCapturesClientContext[T]) Build(clientContext subsystems.ClientContext) (T, error) {
34 c.ReceivedClientContext = clientContext
35 return c.Configurer.Build(clientContext)
36 }
37
View as plain text