TUN-2309: Split ConnectResult into ConnectError and ConnectSuccess, each implementing its own capnp serialization logic

This commit is contained in:
Chung-Ting Huang
2019-09-17 16:58:49 -05:00
parent 4f23da2a6d
commit 5bcb2da0fe
6 changed files with 564 additions and 315 deletions

View File

@@ -11,21 +11,21 @@ import (
capnp "zombiezen.com/go/capnproto2"
)
func sampleTestConnectResult() *ConnectResult {
return &ConnectResult{
Err: &ConnectError{
func TestConnectResult(t *testing.T) {
testCases := []ConnectResult{
&ConnectError{
Cause: "it broke",
ShouldRetry: false,
RetryAfter: 2 * time.Second,
},
ServerInfo: ServerInfo{LocationName: "computer"},
ClientConfig: *sampleClientConfig(),
}
}
func TestConnectResult(t *testing.T) {
testCases := []*ConnectResult{
sampleTestConnectResult(),
&ConnectSuccess{
ServerLocationName: "SFO",
Config: sampleClientConfig(),
},
&ConnectSuccess{
ServerLocationName: "",
Config: nil,
},
}
for i, testCase := range testCases {
_, seg, err := capnp.NewMessage(capnp.SingleSegment(nil))