2014-02-08 00:40:52 +00:00
|
|
|
package structs
|
2014-10-18 01:23:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncodeDecode(t *testing.T) {
|
|
|
|
arg := &RegisterRequest{
|
|
|
|
Datacenter: "foo",
|
|
|
|
Node: "bar",
|
|
|
|
Address: "baz",
|
|
|
|
Service: &NodeService{
|
|
|
|
Service: "test",
|
2015-01-02 21:10:05 +00:00
|
|
|
Address: "127.0.0.2",
|
2014-10-18 01:23:13 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
buf, err := Encode(RegisterRequestType, arg)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var out RegisterRequest
|
|
|
|
err = Decode(buf[1:], &out)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(arg.Service, out.Service) {
|
|
|
|
t.Fatalf("bad: %#v %#v", arg.Service, out.Service)
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(arg, &out) {
|
|
|
|
t.Fatalf("bad: %#v %#v", arg, out)
|
|
|
|
}
|
|
|
|
}
|
2014-10-07 18:05:31 +00:00
|
|
|
|
|
|
|
func TestStructs_Implements(t *testing.T) {
|
|
|
|
var (
|
|
|
|
_ RPCInfo = &RegisterRequest{}
|
|
|
|
_ RPCInfo = &DeregisterRequest{}
|
|
|
|
_ RPCInfo = &DCSpecificRequest{}
|
|
|
|
_ RPCInfo = &ServiceSpecificRequest{}
|
|
|
|
_ RPCInfo = &NodeSpecificRequest{}
|
|
|
|
_ RPCInfo = &ChecksInStateRequest{}
|
|
|
|
_ RPCInfo = &KVSRequest{}
|
|
|
|
_ RPCInfo = &KeyRequest{}
|
|
|
|
_ RPCInfo = &KeyListRequest{}
|
|
|
|
_ RPCInfo = &SessionRequest{}
|
|
|
|
_ RPCInfo = &SessionSpecificRequest{}
|
|
|
|
_ RPCInfo = &EventFireRequest{}
|
|
|
|
_ RPCInfo = &ACLPolicyRequest{}
|
|
|
|
_ RPCInfo = &KeyringRequest{}
|
|
|
|
_ CompoundResponse = &KeyringResponses{}
|
|
|
|
)
|
|
|
|
}
|