File: address_test.go

package info (click to toggle)
golang-github-segmentio-kafka-go 0.4.49%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,292 kB
  • sloc: sh: 17; makefile: 10
file content (55 lines) | stat: -rw-r--r-- 1,033 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package kafka

import (
	"net"
	"testing"
)

func TestNetworkAddress(t *testing.T) {
	tests := []struct {
		addr    net.Addr
		network string
		address string
	}{
		{
			addr:    TCP("127.0.0.1"),
			network: "tcp",
			address: "127.0.0.1:9092",
		},

		{
			addr:    TCP("::1"),
			network: "tcp",
			address: "[::1]:9092",
		},

		{
			addr:    TCP("localhost"),
			network: "tcp",
			address: "localhost:9092",
		},

		{
			addr:    TCP("localhost:9092"),
			network: "tcp",
			address: "localhost:9092",
		},

		{
			addr:    TCP("localhost", "localhost:9093", "localhost:9094"),
			network: "tcp,tcp,tcp",
			address: "localhost:9092,localhost:9093,localhost:9094",
		},
	}

	for _, test := range tests {
		t.Run(test.network+"+"+test.address, func(t *testing.T) {
			if s := test.addr.Network(); s != test.network {
				t.Errorf("network mismatch: want %q but got %q", test.network, s)
			}
			if s := test.addr.String(); s != test.address {
				t.Errorf("network mismatch: want %q but got %q", test.address, s)
			}
		})
	}
}