-
Notifications
You must be signed in to change notification settings - Fork 353
/
Copy pathopen_test.go
55 lines (46 loc) · 1.03 KB
/
open_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package eskipfile
import (
"net/http"
"net/url"
"testing"
"time"
"github.com/zalando/skipper/filters/builtin"
"github.com/zalando/skipper/logging/loggingtest"
"github.com/zalando/skipper/routing"
)
func TestOpenFails(t *testing.T) {
_, err := Open("notexisting.eskip")
if err == nil {
t.Error("failed to fail")
}
}
func TestOpenSucceeds(t *testing.T) {
f, err := Open("fixtures/test.eskip")
if err != nil {
t.Error(err)
return
}
l := loggingtest.New()
defer l.Close()
rt := routing.New(routing.Options{
FilterRegistry: builtin.MakeRegistry(),
DataClients: []routing.DataClient{f},
Log: l,
PollTimeout: 180 * time.Millisecond,
})
defer rt.Close()
if err := l.WaitFor("route settings applied", 120*time.Millisecond); err != nil {
t.Error(err)
return
}
check := func(id, path string) {
r, _ := rt.Route(&http.Request{URL: &url.URL{Path: path}})
if r == nil || r.Id != id {
t.Error("failed to load file")
t.FailNow()
return
}
}
check("foo", "/foo")
check("bar", "/bar")
}