14 lines
492 B
Go
14 lines
492 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestListenAddressDefaultsToLoopbackAndSupportsExplicitBinding(t *testing.T) {
|
|
if got := listenAddress(func(string) string { return "" }); got != "127.0.0.1:8080" {
|
|
t.Fatalf("listenAddress(defaults) = %q", got)
|
|
}
|
|
values := map[string]string{"GO_BACKEND_HOST": "0.0.0.0", "GO_BACKEND_PORT": "9080"}
|
|
if got := listenAddress(func(name string) string { return values[name] }); got != "0.0.0.0:9080" {
|
|
t.Fatalf("listenAddress(explicit) = %q", got)
|
|
}
|
|
}
|