fix tests post-refactor
--HG-- branch : adc
This commit is contained in:
parent
c4c6021c85
commit
b784c34d4d
@ -7,12 +7,13 @@ import (
|
|||||||
func ExampleHubConnectionOptions_Connect() {
|
func ExampleHubConnectionOptions_Connect() {
|
||||||
opts := HubConnectionOptions{
|
opts := HubConnectionOptions{
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
Self: *NewUserInfo("slowpoke9"),
|
Self: NewUserInfo("slowpoke9"),
|
||||||
}
|
}
|
||||||
hub := opts.Connect()
|
|
||||||
|
|
||||||
for {
|
events := make(chan HubEvent, 0)
|
||||||
event := <-hub.OnEvent
|
hub := ConnectAsync(&opts, events)
|
||||||
|
|
||||||
|
for event := range events {
|
||||||
switch event.EventType {
|
switch event.EventType {
|
||||||
case EVENT_CONNECTION_STATE_CHANGED:
|
case EVENT_CONNECTION_STATE_CHANGED:
|
||||||
fmt.Printf("Connection -- %s (%s)\n", event.StateChange, event.Message)
|
fmt.Printf("Connection -- %s (%s)\n", event.StateChange, event.Message)
|
||||||
@ -50,9 +51,8 @@ func ExampleHubConnectionOptions_ConnectSync() {
|
|||||||
|
|
||||||
opts := HubConnectionOptions{
|
opts := HubConnectionOptions{
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
Self: *NewUserInfo("slowpoke9"),
|
Self: NewUserInfo("slowpoke9"),
|
||||||
OnEventSync: cb,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.ConnectSync() // blocking
|
ConnectSync(&opts, cb) // blocking
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type myInfoTestPair struct {
|
func TestMyINFOParse(t *testing.T) {
|
||||||
|
|
||||||
|
np := NewNmdcProtocol(nil).(*NmdcProtocol)
|
||||||
|
|
||||||
|
type myInfoTestPair struct {
|
||||||
in string
|
in string
|
||||||
expect UserInfo
|
expect UserInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMyINFOParse(t *testing.T) {
|
|
||||||
|
|
||||||
cases := []myInfoTestPair{
|
cases := []myInfoTestPair{
|
||||||
|
|
||||||
@ -71,15 +73,14 @@ func TestMyINFOParse(t *testing.T) {
|
|||||||
|
|
||||||
for _, v := range cases {
|
for _, v := range cases {
|
||||||
|
|
||||||
got := UserInfo{}
|
got, err := np.parseMyINFO(v.in)
|
||||||
err := got.fromMyINFO(v.in)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("MyINFO parse warning (%s)", err.Error())
|
t.Errorf("MyINFO parse warning (%s)", err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if got != v.expect {
|
if *got != v.expect {
|
||||||
t.Errorf("MyINFO parse failure\nExpected:\n%+v\nGot:\n%+v\n", v.expect, got)
|
t.Errorf("MyINFO parse failure\nExpected:\n%+v\nGot:\n%+v\n", v.expect, got)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user