mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-08 16:06:47 +00:00
Fix proxy test
The proxy test needed its own local resovler to pass. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
6e537d1fde
commit
1c8e8bb615
@ -16,7 +16,7 @@ func Test_Proxy_ToPrivateServer(t *testing.T) {
|
|||||||
|
|
||||||
wantBodyText := "OK"
|
wantBodyText := "OK"
|
||||||
wantBody := []byte(wantBodyText)
|
wantBody := []byte(wantBodyText)
|
||||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
upstreamSvr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if r.Body != nil {
|
if r.Body != nil {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
@ -27,17 +27,19 @@ func Test_Proxy_ToPrivateServer(t *testing.T) {
|
|||||||
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
defer upstream.Close()
|
defer upstreamSvr.Close()
|
||||||
port := 8080
|
port := 8080
|
||||||
proxy := NewProxy(port, time.Second*1)
|
u, _ := url.Parse(upstreamSvr.URL)
|
||||||
|
log.Println("Host", u.Host)
|
||||||
|
|
||||||
|
upstreamAddr := u.Host
|
||||||
|
proxy := NewProxy(upstreamAddr, 8080, "127.0.0.1", time.Second*1, &mockResolver{})
|
||||||
|
|
||||||
gwChan := make(chan string, 1)
|
gwChan := make(chan string, 1)
|
||||||
doneCh := make(chan bool)
|
doneCh := make(chan bool)
|
||||||
|
|
||||||
go proxy.Start(gwChan, doneCh)
|
go proxy.Start()
|
||||||
|
|
||||||
u, _ := url.Parse(upstream.URL)
|
|
||||||
log.Println("Host", u.Host)
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
@ -71,3 +73,14 @@ func Test_Proxy_ToPrivateServer(t *testing.T) {
|
|||||||
doneCh <- true
|
doneCh <- true
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mockResolver struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockResolver) Start() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockResolver) Get(upstream string, got chan<- string, timeout time.Duration) {
|
||||||
|
got <- upstream
|
||||||
|
}
|
||||||
|
@ -295,8 +295,6 @@ func ParseCompose(config *compose.Config) ([]Service, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Service: %s - %v\n", s.Name, s.Ports)
|
|
||||||
|
|
||||||
services[idx] = Service{
|
services[idx] = Service{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
Image: s.Image,
|
Image: s.Image,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user