1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-26 06:50:36 +08:00

TUN-2551: TunnelRPC definitions for ReconnectTunnel flow

This commit is contained in:
Nick Vollmar
2019-11-18 13:56:04 -06:00
parent ca7fbf43da
commit 0676923d24
5 changed files with 620 additions and 239 deletions

View File

@@ -11,6 +11,36 @@ import (
capnp "zombiezen.com/go/capnproto2"
)
func TestTunnelRegistration(t *testing.T) {
testCases := []*TunnelRegistration{
&TunnelRegistration{
Err: "it broke",
Url: "asdf.cftunnel.com",
LogLines: []string{"it", "was", "broken"},
PermanentFailure: true,
TunnelID: "asdfghjkl;",
RetryAfterSeconds: 19,
},
}
for i, testCase := range testCases {
_, seg, err := capnp.NewMessage(capnp.SingleSegment(nil))
capnpEntity, err := tunnelrpc.NewTunnelRegistration(seg)
if !assert.NoError(t, err) {
t.Fatal("Couldn't initialize a new message")
}
err = MarshalTunnelRegistration(capnpEntity, testCase)
if !assert.NoError(t, err, "testCase #%v failed to marshal", i) {
continue
}
result, err := UnmarshalTunnelRegistration(capnpEntity)
if !assert.NoError(t, err, "testCase #%v failed to unmarshal", i) {
continue
}
assert.Equal(t, testCase, result, "testCase index %v didn't preserve struct through marshalling and unmarshalling", i)
}
}
func TestConnectResult(t *testing.T) {
testCases := []ConnectResult{
&ConnectError{