mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
api/client.go: implement Client.Subscribe correctly by returning a error on unsupported channel type.
This commit is contained in:
parent
9e586d879d
commit
8154bee1c2
2 changed files with 35 additions and 3 deletions
26
api/client_test.go
Normal file
26
api/client_test.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClient_Subscribe(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
channel Channel
|
||||
wantErr bool
|
||||
}{
|
||||
{"Channel", Channel{}, true},
|
||||
{"ActionChannel", ActionChannel{}.Channel(), false},
|
||||
{"HeartbeatChannel", HeartbeatChannel, false},
|
||||
{"TransactionChannel", TransactionChannel, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := Client{}
|
||||
if err := c.Subscribe(tt.channel); (err != nil) != tt.wantErr {
|
||||
t.Errorf("Client.Subscribe() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue