-
Notifications
You must be signed in to change notification settings - Fork 14
/
hooks.go
37 lines (31 loc) · 1.12 KB
/
hooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package temporal_tester
import (
"context"
"github.com/anz-bank/sysl-go/core"
"github.com/anz-bank/sysl-go/syslgo"
"github.com/stretchr/testify/require"
)
// TODO: use this on other test services.
func PatchedService[
AppConfig, ServiceInterface any,
](
t syslgo.TestingT,
createService core.ServiceDefinition[AppConfig, ServiceInterface],
testHooks *core.Hooks,
withActualDownstreams bool,
) func(context.Context, AppConfig) (ServiceInterface, *core.Hooks, error) {
return func(ctx context.Context, ac AppConfig) (ServiceInterface, *core.Hooks, error) {
svc, hooks, err := createService(ctx, ac)
require.NoError(t, err)
hooks.ShouldSetGrpcGlobalLogger = testHooks.ShouldSetGrpcGlobalLogger
hooks.HTTPClientBuilder = testHooks.HTTPClientBuilder
hooks.StoppableServerBuilder = testHooks.StoppableServerBuilder
hooks.StoppableGrpcServerBuilder = testHooks.StoppableGrpcServerBuilder
hooks.ValidateConfig = testHooks.ValidateConfig
if !withActualDownstreams {
hooks.ExperimentalTemporalClientBuilder = EmptyClientsBuilder
hooks.ExperimentalTemporalWorkerBuilder = MockWorkerBuilder
}
return svc, hooks, nil
}
}