Fix tests

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-11-16 17:52:46 -03:00
parent 654eceda46
commit af2dce901d
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
5 changed files with 55 additions and 26 deletions

View file

@ -24,6 +24,7 @@ import (
"net/http/httptest"
"strings"
"testing"
"time"
jsoniter "github.com/json-iterator/go"
apiv1 "k8s.io/api/core/v1"
@ -146,7 +147,33 @@ func TestIsDynamicConfigurationEnough(t *testing.T) {
}
}
func mockUnixSocket(t *testing.T) net.Listener {
l, err := net.Listen("unix", nginxStreamSocket)
if err != nil {
t.Fatalf("unexpected error creating unix socket: %v", err)
}
if l == nil {
t.Fatalf("expected a listener but none returned")
}
go func() {
for {
conn, err := l.Accept()
if err != nil {
continue
}
time.Sleep(100 * time.Millisecond)
defer conn.Close()
}
}()
return l
}
func TestConfigureDynamically(t *testing.T) {
l := mockUnixSocket(t)
defer l.Close()
target := &apiv1.ObjectReference{}
backends := []*ingress.Backend{{