Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prefix in key value stores #1487

Merged
merged 3 commits into from Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion jetstream/kv.go
Expand Up @@ -411,7 +411,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
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
Expand Up @@ -1062,7 +1062,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
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