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

[FIXED] Display all configured channels #1107

Merged
merged 1 commit into from
Oct 13, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ func getTestDefaultOptsForPersistentStore() *Options {
case stores.TypeFile:
opts.FilestoreDir = defaultDataStore
opts.FileStoreOpts.BufferSize = 1024
// Go 1.12 on macOS is very slow at doing sync writes...
if runtime.GOOS == "darwin" && strings.HasPrefix(runtime.Version(), "go1.12") {
// Since Go 1.12, on macOS it is very slow to do sync writes...
if runtime.GOOS == "darwin" {
opts.FileStoreOpts.DoSync = false
}
case stores.TypeSQL:
Expand Down
9 changes: 7 additions & 2 deletions util/sublist.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ func (s *Sublist) Subjects() []string {

func getSubjects(l *level, subject string, res *[]string) {
if l == nil || l.numNodes() == 0 {
*res = append(*res, subject)
return
}
var fs string
Expand All @@ -500,14 +499,17 @@ func getSubjects(l *level, subject string, res *[]string) {
} else {
fs = sfwc
}
getSubjects(l.fwc.next, fs, res)
*res = append(*res, fs)
}
if l.pwc != nil {
if subject != "" {
fs = subject + tsep + spwc
} else {
fs = spwc
}
if len(l.pwc.elements) > 0 {
*res = append(*res, fs)
}
getSubjects(l.pwc.next, fs, res)
}
for s, n := range l.nodes {
Expand All @@ -516,6 +518,9 @@ func getSubjects(l *level, subject string, res *[]string) {
} else {
fs = s
}
if len(n.elements) > 0 {
*res = append(*res, fs)
}
getSubjects(n.next, fs, res)
}
}
29 changes: 29 additions & 0 deletions util/sublist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,33 @@ func TestSublistSubjects(t *testing.T) {
t.Fatalf("Result expected to be either %v or %v, got %v", pOne, pTwo, r)
}
}

subjects = []string{"bar", "bar.*", "bar.baz", "bar.>", "bar.*.bat", "bar.baz.*", "bar.baz.biz.box", "bar.baz.>"}
expected := []string{"bar", "bar.>", "bar.*", "bar.*.bat", "bar.baz", "bar.baz.>", "bar.baz.*", "bar.baz.biz.box"}
s := NewSublist()
for _, subj := range subjects {
s.Insert(subj, subj)
}
r := s.Match("bar")
if len(r) == 0 {
t.Fatalf("bar should be in the sublist")
}
if r[0].(string) != "bar" {
t.Fatalf("invalid value for bar: %q", r[0].(string))
}
subjs := s.Subjects()
if !reflect.DeepEqual(subjs, expected) {
t.Fatalf("Expected subject:\n%q\n got\n%q", expected, subjs)
}

subjects = []string{"bar", "bar.*.*.box", "bar.baz.bat.*", ">", "*", "bar.baz.bat"}
expected = []string{">", "*", "bar", "bar.*.*.box", "bar.baz.bat", "bar.baz.bat.*"}
s = NewSublist()
for _, subj := range subjects {
s.Insert(subj, subj)
}
subjs = s.Subjects()
if !reflect.DeepEqual(subjs, expected) {
t.Fatalf("Expected subject:\n%q\n got\n%q", expected, subjs)
}
}