aboutsummaryrefslogtreecommitdiff
path: root/server/config_test.go
blob: 8787e467b69500e6163eb2bab50130c8eb74209d (plain) (blame)
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
package server

import "testing"

func TestConfigAddress(t *testing.T) {
	cfg := Config{Host: "foobar", Port: "1234"}
	if actual, expected := cfg.Address(), "foobar:1234"; expected != actual {
		t.Errorf("Expected '%s' but got '%s'", expected, actual)
	}

	cfg = Config{Host: "", Port: "1234"}
	if actual, expected := cfg.Address(), ":1234"; expected != actual {
		t.Errorf("Expected '%s' but got '%s'", expected, actual)
	}

	cfg = Config{Host: "foobar", Port: ""}
	if actual, expected := cfg.Address(), "foobar:"; expected != actual {
		t.Errorf("Expected '%s' but got '%s'", expected, actual)
	}

	cfg = Config{Host: "::1", Port: "443"}
	if actual, expected := cfg.Address(), "[::1]:443"; expected != actual {
		t.Errorf("Expected '%s' but got '%s'", expected, actual)
	}
}