Add tests for bind-address
This commit is contained in:
parent
df61bd7565
commit
a085808d2d
4 changed files with 33 additions and 10 deletions
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package template
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
|
|
@ -75,6 +76,19 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
t.Errorf("unexpected diff: (-got +want)\n%s", diff)
|
||||
}
|
||||
|
||||
to = ReadConfig(conf)
|
||||
def.BindAddressIpv4 = []string{}
|
||||
def.BindAddressIpv6 = []string{}
|
||||
|
||||
if !reflect.DeepEqual(to.BindAddressIpv4, []string{"1.1.1.1", "2.2.2.2"}) {
|
||||
t.Errorf("unexpected bindAddressIpv4")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(to.BindAddressIpv6, []string{"[2001:db8:a0b:12f0::1]", "[3731:54:65fe:2::a7]"}) {
|
||||
t.Logf("%v", to.BindAddressIpv6)
|
||||
t.Errorf("unexpected bindAddressIpv6")
|
||||
}
|
||||
|
||||
def = config.NewDefault()
|
||||
to = ReadConfig(map[string]string{})
|
||||
if diff := pretty.Compare(to, def); diff != "" {
|
||||
|
|
|
|||
|
|
@ -483,10 +483,22 @@ func TestTemplateWithData(t *testing.T) {
|
|||
t.Errorf("invalid NGINX template: %v", err)
|
||||
}
|
||||
|
||||
_, err = ngxTpl.Write(dat)
|
||||
rt, err := ngxTpl.Write(dat)
|
||||
if err != nil {
|
||||
t.Errorf("invalid NGINX template: %v", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(string(rt), "listen [2001:db8:a0b:12f0::1]") {
|
||||
t.Errorf("invalid NGINX template, expected IPV6 listen address not present")
|
||||
}
|
||||
|
||||
if !strings.Contains(string(rt), "listen [3731:54:65fe:2::a7]") {
|
||||
t.Errorf("invalid NGINX template, expected IPV6 listen address not present")
|
||||
}
|
||||
|
||||
if !strings.Contains(string(rt), "listen 2.2.2.2") {
|
||||
t.Errorf("invalid NGINX template, expected IPV4 listen address not present")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTemplateWithData(b *testing.B) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue