MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestKVList

Function TestKVList

integration/kv_test.go:26–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestKVList(t *testing.T) {
27 testKVs(t, func(t *testing.T, client kv.Client, reg *prometheus.Registry) {
28 // Create keys to list back
29 keysToCreate := []string{"key-a", "key-b", "key-c"}
30 for _, key := range keysToCreate {
31 err := client.CAS(context.Background(), key, func(in interface{}) (out interface{}, retry bool, err error) {
32 return key, false, nil
33 })
34 require.NoError(t, err, "could not create key")
35 }
36
37 // Get list of keys and sort them
38 keys, err := client.List(context.Background(), "")
39 require.NoError(t, err, "could not list keys")
40 sort.Strings(keys)
41 require.Equal(t, keysToCreate, keys, "returned key paths did not match created paths")
42
43 verifyClientMetricsHistogram(t, reg, "cortex_kv_request_duration_seconds", map[string]uint64{
44 "List": 1,
45 "CAS": 3,
46 })
47 })
48}
49
50func TestKVDelete(t *testing.T) {
51 testKVs(t, func(t *testing.T, client kv.Client, reg *prometheus.Registry) {

Callers

nothing calls this directly

Calls 5

testKVsFunction · 0.85
CASMethod · 0.65
ListMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected