fix tests post-refactor

--HG--
branch : adc
This commit is contained in:
mappu 2017-11-25 13:45:10 +13:00
parent c4c6021c85
commit b784c34d4d
2 changed files with 17 additions and 16 deletions

View File

@ -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)
@ -49,10 +50,9 @@ 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
} }

View File

@ -4,13 +4,15 @@ import (
"testing" "testing"
) )
type myInfoTestPair struct {
in string
expect UserInfo
}
func TestMyINFOParse(t *testing.T) { func TestMyINFOParse(t *testing.T) {
np := NewNmdcProtocol(nil).(*NmdcProtocol)
type myInfoTestPair struct {
in string
expect UserInfo
}
cases := []myInfoTestPair{ cases := []myInfoTestPair{
myInfoTestPair{ 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
} }