-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathmain_test.go
61 lines (53 loc) · 1.45 KB
/
main_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
56
57
58
59
60
61
package main
import (
"testing"
ftypes "github.com/openfaas/faas-provider/types"
)
func Test_makeFunctionURL_DefaultPathQS_IncludesGWAddress(t *testing.T) {
config := QueueWorkerConfig{
FunctionSuffix: "",
GatewayAddress: "gateway",
GatewayPort: 8080,
}
req := ftypes.QueueRequest{
Function: "function1",
Path: "/",
}
fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString)
wantURL := "http://gateway:8080/function/function1/"
if fnURL != wantURL {
t.Errorf("want %s, got %s", wantURL, fnURL)
}
}
func Test_makeFunctionURL_DefaultPathQS_WithQS(t *testing.T) {
config := QueueWorkerConfig{
FunctionSuffix: "",
GatewayAddress: "gateway",
GatewayPort: 8080,
}
req := ftypes.QueueRequest{
Function: "function1",
QueryString: "user=1",
}
fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString)
wantURL := "http://gateway:8080/function/function1/?user=1"
if fnURL != wantURL {
t.Errorf("want %s, got %s", wantURL, fnURL)
}
}
func Test_makeFunctionURL_DefaultPathQS_WithPath(t *testing.T) {
config := QueueWorkerConfig{
FunctionSuffix: "",
GatewayAddress: "gateway",
GatewayPort: 8080,
}
req := ftypes.QueueRequest{
Function: "function1",
Path: "/resources/main.css",
}
fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString)
wantURL := "http://gateway:8080/function/function1/resources/main.css"
if fnURL != wantURL {
t.Errorf("want %s, got %s", wantURL, fnURL)
}
}