func testList(t *testing.T, kv store.Store) { prefix := "testList" firstKey := "testList/first" firstValue := []byte("first") secondKey := "testList/second" secondValue := []byte("second") // Put the first key err := kv.Put(firstKey, firstValue, nil) assert.NoError(t, err) // Put the second key err = kv.Put(secondKey, secondValue, nil) assert.NoError(t, err) // List should work and return the two correct values for _, parent := range []string{prefix, prefix + "/"} { pairs, err := kv.List(parent) assert.NoError(t, err) if assert.NotNil(t, pairs) { assert.Equal(t, len(pairs), 2) } // Check pairs, those are not necessarily in Put order for _, pair := range pairs { if pair.Key == firstKey { assert.Equal(t, pair.Value, firstValue) } if pair.Key == secondKey { assert.Equal(t, pair.Value, secondValue) } } } // List should fail: the key does not exist pairs, err := kv.List("idontexist") assert.Equal(t, store.ErrKeyNotFound, err) assert.Nil(t, pairs) }