forked from aertje/cloud-tasks-emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_internal_test.go
71 lines (59 loc) · 2.27 KB
/
task_internal_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
62
63
64
65
66
67
68
69
70
71
package main
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2"
)
func TestSetInitialTaskStateAppEngineNoEmulatorDefaults(t *testing.T) {
taskState := &taskspb.Task{
MessageType: &taskspb.Task_AppEngineHttpRequest{
AppEngineHttpRequest: &taskspb.AppEngineHttpRequest{},
},
}
setInitialTaskState(taskState, "projects/bluebook/locations/us-east1/queues/agentq")
assert.Equal(t, "https://bluebook.appspot.com", taskState.GetAppEngineHttpRequest().GetAppEngineRouting().GetHost())
}
func TestInitialTaskStateAppEngineNoEmulatorTargeted(t *testing.T) {
taskState := &taskspb.Task{
MessageType: &taskspb.Task_AppEngineHttpRequest{
AppEngineHttpRequest: &taskspb.AppEngineHttpRequest{
AppEngineRouting: &taskspb.AppEngineRouting{
Service: "worker",
Version: "v1",
Instance: "2",
},
},
},
}
setInitialTaskState(taskState, "projects/bluebook/locations/us-east1/queues/agentq")
assert.Equal(t, "https://2-dot-v1-dot-worker-dot-bluebook.appspot.com", taskState.GetAppEngineHttpRequest().GetAppEngineRouting().GetHost())
}
func TestSetInitialTaskStateAppEngineEmulatorDefaults(t *testing.T) {
defer os.Unsetenv("APP_ENGINE_EMULATOR_HOST")
os.Setenv("APP_ENGINE_EMULATOR_HOST", "http://localhost:1234")
taskState := &taskspb.Task{
MessageType: &taskspb.Task_AppEngineHttpRequest{
AppEngineHttpRequest: &taskspb.AppEngineHttpRequest{},
},
}
setInitialTaskState(taskState, "projects/bluebook/locations/us-east1/queues/agentq")
assert.Equal(t, "http://localhost:1234", taskState.GetAppEngineHttpRequest().GetAppEngineRouting().GetHost())
}
func TestSetInitialTaskStateAppEngineEmulatorTargeted(t *testing.T) {
defer os.Unsetenv("APP_ENGINE_EMULATOR_HOST")
os.Setenv("APP_ENGINE_EMULATOR_HOST", "http://nginx")
taskState := &taskspb.Task{
MessageType: &taskspb.Task_AppEngineHttpRequest{
AppEngineHttpRequest: &taskspb.AppEngineHttpRequest{
AppEngineRouting: &taskspb.AppEngineRouting{
Service: "worker",
Version: "v1",
Instance: "2",
},
},
},
}
setInitialTaskState(taskState, "projects/bluebook/locations/us-east1/queues/agentq")
assert.Equal(t, "http://2.v1.worker.nginx", taskState.GetAppEngineHttpRequest().GetAppEngineRouting().GetHost())
}