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

Function TestBackendConfig_Validate

cache/cache_test.go:9–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestBackendConfig_Validate(t *testing.T) {
10 t.Run("empty backend", func(t *testing.T) {
11 cfg := BackendConfig{}
12 memcachedClientConfigDefaultValues(&cfg.Memcached)
13
14 require.NoError(t, cfg.Validate())
15 })
16
17 t.Run("invalid backend", func(t *testing.T) {
18 cfg := BackendConfig{
19 Backend: "invalid",
20 }
21
22 require.Error(t, cfg.Validate())
23 })
24
25 t.Run("memcached backend valid", func(t *testing.T) {
26 cfg := BackendConfig{}
27 memcachedClientConfigDefaultValues(&cfg.Memcached)
28
29 cfg.Backend = BackendMemcached
30 cfg.Memcached.Addresses = []string{"localhost:11211"}
31 cfg.Memcached.MaxAsyncConcurrency = 1
32
33 require.NoError(t, cfg.Validate())
34 })
35
36 t.Run("memcached backend invalid", func(t *testing.T) {
37 cfg := BackendConfig{}
38 memcachedClientConfigDefaultValues(&cfg.Memcached)
39
40 cfg.Backend = BackendMemcached
41 cfg.Memcached.Addresses = []string{}
42
43 require.Equal(t, ErrNoMemcachedAddresses, cfg.Validate())
44 })
45}

Callers

nothing calls this directly

Calls 5

ValidateMethod · 0.95
RunMethod · 0.80
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected