MCPcopy Create free account
hub / github.com/DoNewsCode/core / TestFactoryOut_ProvideRunGroup

Function TestFactoryOut_ProvideRunGroup

otredis/integration_test.go:18–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestFactoryOut_ProvideRunGroup(t *testing.T) {
19 if os.Getenv("REDIS_ADDR") == "" {
20 t.Skip("set REDIS_ADDR to run TestModule_ProvideRunGroup")
21 return
22 }
23 addrs := strings.Split(os.Getenv("REDIS_ADDR"), ",")
24 t.Parallel()
25
26 ctrl := gomock.NewController(t)
27 defer ctrl.Finish()
28
29 called := false
30
31 withValues := []interface{}{
32 gomock.Eq("dbname"),
33 gomock.Eq("default"),
34 }
35
36 m := mock_metrics.NewMockGauge(ctrl)
37 m.EXPECT().With(withValues...).Return(m).MinTimes(1)
38 m.EXPECT().Set(gomock.Any()).MinTimes(1)
39
40 c := core.New(
41 core.WithInline("redis.default.addrs", addrs),
42 core.WithInline("redisMetrics.interval", "1ms"),
43 core.WithInline("log.level", "none"),
44 )
45 c.ProvideEssentials()
46 c.Provide(di.Deps{func() *Gauges {
47 return &Gauges{
48 Hits: m,
49 Misses: m,
50 Timeouts: m,
51 TotalConns: m,
52 IdleConns: m,
53 StaleConns: m,
54 }
55 }})
56 c.Provide(Providers(WithConfigInterceptor(func(name string, opts *redis.UniversalOptions) {
57 called = true
58 }), WithReload(true)))
59
60 ctx, cancel := context.WithCancel(context.Background())
61
62 c.Invoke(func(cli redis.UniversalClient) {
63 cli.ClientID(ctx)
64 })
65
66 go c.Serve(ctx)
67 <-time.After(10 * time.Millisecond)
68 cancel()
69 <-time.After(1000 * time.Millisecond)
70 assert.True(t, called)
71}

Callers

nothing calls this directly

Calls 12

EXPECTMethod · 0.95
NewFunction · 0.92
WithInlineFunction · 0.92
ProvideEssentialsMethod · 0.80
ProvideMethod · 0.80
InvokeMethod · 0.80
ServeMethod · 0.80
ProvidersFunction · 0.70
WithConfigInterceptorFunction · 0.70
WithReloadFunction · 0.70
WithMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected