MCPcopy
hub / github.com/grafana/dskit / withFixtures

Function withFixtures

kv/kv_test.go:20–45  ·  view source on GitHub ↗
(t *testing.T, f func(*testing.T, Client))

Source from the content-addressed store, hash-verified

18)
19
20func withFixtures(t *testing.T, f func(*testing.T, Client)) {
21 t.Helper()
22
23 for _, fixture := range []struct {
24 name string
25 factory func() (Client, io.Closer, error)
26 }{
27 {"consul", func() (Client, io.Closer, error) {
28 client, closer := consul.NewInMemoryClient(codec.String{}, testLogger{}, nil)
29 return client, closer, nil
30 }},
31 {"etcd", func() (Client, io.Closer, error) {
32 client, closer := etcd.NewInMemoryClient(codec.String{}, testLogger{})
33 return client, closer, nil
34 }},
35 } {
36 t.Run(fixture.name, func(t *testing.T) {
37 client, closer, err := fixture.factory()
38 require.NoError(t, err)
39 t.Cleanup(func() {
40 _ = closer.Close()
41 })
42 f(t, client)
43 })
44 }
45}
46
47var (
48 ctx = context.Background()

Callers 5

TestCASFunction · 0.70
TestNilCASFunction · 0.70
TestWatchKeyFunction · 0.70
TestWatchPrefixFunction · 0.70
TestListFunction · 0.70

Calls 5

NewInMemoryClientFunction · 0.92
NewInMemoryClientFunction · 0.92
HelperMethod · 0.80
RunMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected