mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-29 12:16:16 +08:00
26 lines
781 B
Go
26 lines
781 B
Go
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: "https"}
|
|
if actual, expected := cfg.Address(), "[::1]:https"; expected != actual {
|
|
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
|
}
|
|
}
|