-
Notifications
You must be signed in to change notification settings - Fork 0
/
origin_test.go
36 lines (31 loc) · 1.05 KB
/
origin_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
package stargate
import (
"errors"
"testing"
)
func TestNewOriginServer(t *testing.T) {
tests := []struct {
name string
address string
err error
}{
{"check for unsupported schemes", "invalid://some-address", errUnknownScheme},
{"check that URLs without a scheme return an error", "some-address", errUnknownScheme},
{"check that http servers are created", "http://some-address", nil},
{"check that https servers are created", "https://some-address", nil},
{"check that websocket servers are created", "ws://some-address", nil},
{"check that websocket secured servers are created", "wss://some-address", nil},
}
for _, test := range tests {
t.Logf("running test %q", test.name)
_, err := NewOriginServer(&RouteOptions{Address: test.address}, defaultDirector("/"))
if err != nil {
if test.err == nil {
t.Fatalf("NewDownstreamServer unexpectedly returned an error: %v", err)
}
if !errors.Is(err, test.err) {
t.Fatalf("NewDownstreamServer returned an incorrect error [%v] - expected %v", err, test.err)
}
}
}
}