mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-22 14:52:31 -04:00
bind: support multiple values (#2128)
Signed-off-by: Shengjing Zhu <i@zhsj.me>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user