Skip to content

Commit

Permalink
Subscriptions: Add List.Authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Aug 19, 2024
1 parent 17c2ef2 commit 1a5c59e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions exchanges/subscription/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ func (l List) Clone() List {
return n
}

// Authenticated returns only Authenticated subscriptions
func (l List) Authenticated() List {
a := List{}
for _, s := range l {
if s.Authenticated {
a = append(a, s)
}
}
return a
}

// QualifiedChannels returns a sorted list of all the qualified Channels in the list
func (l List) QualifiedChannels() []string {
c := make([]string, len(l))
Expand Down
6 changes: 6 additions & 0 deletions exchanges/subscription/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ func TestListClone(t *testing.T) {
l[0].Interval = kline.OneHour
assert.NotEqual(t, n[0], l[0], "Subscriptions should be cloned")
}

func TestListAuthenticated(t *testing.T) {
t.Parallel()
assert.NotEmpty(t, 1, List{{}, {Authenticated: true}}.Authenticated(), "Authenticated should return correct length")
assert.Empty(t, List{{}, {}}.Authenticated(), "Authenticated should return empty")
}

0 comments on commit 1a5c59e

Please sign in to comment.