test ListDirectoryPrefixedEntries

This commit is contained in:
Устюжанин Антон Александрович 2020-08-06 00:24:31 +05:00
parent 2d3b355fb6
commit a457c308ad
8 changed files with 56 additions and 8 deletions

View file

@ -199,8 +199,10 @@ func (store *AbstractSqlStore) ListDirectoryPrefixedEntries(ctx context.Context,
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -210,10 +212,14 @@ func (store *AbstractSqlStore) ListDirectoryPrefixedEntries(ctx context.Context,
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -137,8 +137,10 @@ func (store *CassandraStore) ListDirectoryPrefixedEntries(ctx context.Context, f
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -148,10 +150,14 @@ func (store *CassandraStore) ListDirectoryPrefixedEntries(ctx context.Context, f
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -145,8 +145,10 @@ func (store *EtcdStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpa
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -156,10 +158,14 @@ func (store *EtcdStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpa
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -170,8 +170,10 @@ func (store *LevelDBStore) ListDirectoryPrefixedEntries(ctx context.Context, ful
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -181,10 +183,14 @@ func (store *LevelDBStore) ListDirectoryPrefixedEntries(ctx context.Context, ful
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -179,8 +179,10 @@ func (store *LevelDB2Store) ListDirectoryPrefixedEntries(ctx context.Context, fu
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -190,10 +192,14 @@ func (store *LevelDB2Store) ListDirectoryPrefixedEntries(ctx context.Context, fu
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -178,8 +178,10 @@ func (store *MongodbStore) ListDirectoryPrefixedEntries(ctx context.Context, ful
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -189,10 +191,14 @@ func (store *MongodbStore) ListDirectoryPrefixedEntries(ctx context.Context, ful
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -131,8 +131,10 @@ func (store *UniversalRedisStore) ListDirectoryPrefixedEntries(ctx context.Conte
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -142,10 +144,14 @@ func (store *UniversalRedisStore) ListDirectoryPrefixedEntries(ctx context.Conte
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil

View file

@ -127,8 +127,10 @@ func (store *UniversalRedis2Store) ListDirectoryPrefixedEntries(ctx context.Cont
if prefix == "" { if prefix == "" {
return notPrefixed, nil return notPrefixed, nil
} }
var lastFileName string
for count < limit { for count < limit {
for _, entry := range notPrefixed { for _, entry := range notPrefixed {
lastFileName = entry.Name()
if strings.HasPrefix(entry.Name(), prefix) { if strings.HasPrefix(entry.Name(), prefix) {
count++ count++
entries = append(entries, entry) entries = append(entries, entry)
@ -138,10 +140,14 @@ func (store *UniversalRedis2Store) ListDirectoryPrefixedEntries(ctx context.Cont
break break
} }
notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, startFileName, inclusive, limit) notPrefixed, err = store.ListDirectoryEntries(ctx, fullpath, lastFileName, inclusive, limit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(notPrefixed) == 0 {
break
}
} }
return entries, nil return entries, nil