-
Notifications
You must be signed in to change notification settings - Fork 4
/
iproto_test.go
44 lines (39 loc) · 946 Bytes
/
iproto_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package iproto
import (
"testing"
"bytes"
)
func TestConnect(t *testing.T) {
var (
rid int32
response *Response
err error
conn *IProto
)
conn, err = Connect("localhost:33013")
if err != nil {
t.Errorf("Error: %s", err.Error())
}
rid = 17
response, err = conn.Request(rid, new(bytes.Buffer))
if err != nil {
t.Errorf("Error: %s", err.Error())
}
if response.requestType != rid {
t.Errorf("Error: requestType should be %d, not %d", rid, response.requestType)
}
if response.requestID != 1 {
t.Errorf("Error: requestID should be %d, not %d", 1, response.requestID)
}
rid = 20
response, err = conn.Request(rid, new(bytes.Buffer))
if err != nil {
t.Errorf("Error: %s", err.Error())
}
if response.requestType != rid {
t.Errorf("Error: requestType should be %d, not %d", rid, response.requestType)
}
if response.requestID != 2 {
t.Errorf("Error: requestID should be %d, not %d", 2, response.requestID)
}
}