File: port_forward_channel_open_test.go

package info (click to toggle)
golang-github-microsoft-dev-tunnels 0.0.25-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,988 kB
  • sloc: cs: 9,969; java: 2,767; javascript: 328; xml: 186; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 913 bytes parent folder | download
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

package messages

import (
	"bytes"
	"testing"
)

func TestUnmarshalPortForwardChannel(t *testing.T) {
	pfc := NewPortForwardChannel(11, "127.0.0.1", 8001, "999", 8002)
	b, err := pfc.Marshal()
	if err != nil {
		t.Error(err)
	}

	buf := bytes.NewReader(b)
	pfc2 := &PortForwardChannel{}
	if err := pfc2.Unmarshal(buf); err != nil {
		t.Error(err)
	}

	if pfc2.host != pfc.host {
		t.Errorf("host: expected %v, got %v", pfc.host, pfc2.host)
	}

	if pfc2.port != pfc.port {
		t.Errorf("port: expected %v, got %v", pfc.port, pfc2.port)
	}

	if pfc2.originatorIPAddress != pfc.originatorIPAddress {
		t.Errorf("originHost: expected %v, got %v", pfc.originatorIPAddress, pfc2.originatorIPAddress)
	}

	if pfc2.originatorPort != pfc.originatorPort {
		t.Errorf("originPort: expected %v, got %v", pfc.originatorPort, pfc2.originatorPort)
	}
}