bind: support multiple values (#2128)

Signed-off-by: Shengjing Zhu <i@zhsj.me>
This commit is contained in:
zhsj
2018-11-27 09:27:58 +08:00
committed by Matt Holt
parent 764c9ec956
commit 3a810c6502
8 changed files with 114 additions and 38 deletions
+26
View File
@@ -15,6 +15,7 @@
package httpserver
import (
"reflect"
"strings"
"testing"
@@ -347,3 +348,28 @@ func TestHideCaddyfile(t *testing.T) {
}
t.Fatal("Caddyfile missing from HiddenFiles")
}
func TestGroupSiteConfigsByListenAddr(t *testing.T) {
cfg := []*SiteConfig{
{
ListenHosts: []string{"127.0.0.1", "::1"},
},
{
Addr: Address{
Port: "80",
},
},
}
groups, err := groupSiteConfigsByListenAddr(cfg)
if err != nil {
t.Fatal("Failed to group SiteConfigs by listen address")
}
actual := []string{}
for k := range groups {
actual = append(actual, k)
}
expected := []string{"127.0.0.1:" + Port, "[::1]:" + Port, ":80"}
if !reflect.DeepEqual(actual, expected) {
t.Errorf("Expected listen on %#v, but got %#v", expected, actual)
}
}