Skip to content

Commit

Permalink
[FIXED] KV_ prefix when listing key value stores (#1487)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Dec 12, 2023
1 parent 55224f3 commit f8caaf9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jetstream/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func (js *jetStream) KeyValueStoreNames(ctx context.Context) KeyValueNamesLister
if !strings.HasPrefix(name, kvBucketNamePre) {
continue
}
res.kvNames <- name
res.kvNames <- strings.TrimPrefix(name, kvBucketNamePre)
}
if errors.Is(err, ErrEndOfData) {
return
Expand Down
3 changes: 3 additions & 0 deletions jetstream/test/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ func TestListKeyValueStores(t *testing.T) {
names := make([]string, 0)
kvNames := js.KeyValueStoreNames(ctx)
for name := range kvNames.Name() {
if strings.HasPrefix(name, "KV_") {
t.Fatalf("Expected name without KV_ prefix, got %q", name)
}
names = append(names, name)
}
if kvNames.Error() != nil {
Expand Down
2 changes: 1 addition & 1 deletion kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ func (js *js) KeyValueStoreNames() <-chan string {
if !strings.HasPrefix(name, kvBucketNamePre) {
continue
}
ch <- name
ch <- strings.TrimPrefix(name, kvBucketNamePre)
}
}
}()
Expand Down
3 changes: 3 additions & 0 deletions test/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ func TestListKeyValueStores(t *testing.T) {
}
names := make([]string, 0)
for name := range js.KeyValueStoreNames() {
if strings.HasPrefix(name, "KV_") {
t.Fatalf("Expected name without KV_ prefix, got %q", name)
}
names = append(names, name)
}
if len(names) != test.bucketsNum {
Expand Down

0 comments on commit f8caaf9

Please sign in to comment.