Unify the store tests (#1952)

Add more tests for store
This commit is contained in:
Dominic Wong
2020-08-19 23:41:03 +01:00
committed by Vasiliy Tolstov
parent eee5b98d78
commit d5da9c0728
5 changed files with 571 additions and 97 deletions

View File

@@ -136,13 +136,19 @@ func (m *memoryStore) list(prefix string, limit, offset uint) []string {
if limit != 0 || offset != 0 {
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
min := func(i, j uint) uint {
if i < j {
return i
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
end := len(allKeys)
if limit > 0 {
calcLimit := int(offset + limit)
if calcLimit < end {
end = calcLimit
}
return j
}
return allKeys[offset:min(limit, uint(len(allKeys)))]
if int(offset) >= end {
return nil
}
return allKeys[offset:end]
}
return allKeys