This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
fixtures.go
123 lines (114 loc) · 3.33 KB
/
fixtures.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package testing
import (
"fmt"
"net/http"
"testing"
"time"
"github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/services"
th "github.com/huaweicloud/golangsdk/testhelper"
"github.com/huaweicloud/golangsdk/testhelper/client"
)
// ServiceListBody is sample response to the List call
const ServiceListBody = `
{
"services": [
{
"id": 1,
"binary": "nova-scheduler",
"disabled_reason": "test1",
"host": "host1",
"state": "up",
"status": "disabled",
"updated_at": "2012-10-29T13:42:02.000000",
"forced_down": false,
"zone": "internal"
},
{
"id": 2,
"binary": "nova-compute",
"disabled_reason": "test2",
"host": "host1",
"state": "up",
"status": "disabled",
"updated_at": "2012-10-29T13:42:05.000000",
"forced_down": false,
"zone": "nova"
},
{
"id": 3,
"binary": "nova-scheduler",
"disabled_reason": null,
"host": "host2",
"state": "down",
"status": "enabled",
"updated_at": "2012-09-19T06:55:34.000000",
"forced_down": false,
"zone": "internal"
},
{
"id": 4,
"binary": "nova-compute",
"disabled_reason": "test4",
"host": "host2",
"state": "down",
"status": "disabled",
"updated_at": "2012-09-18T08:03:38.000000",
"forced_down": false,
"zone": "nova"
}
]
}
`
// First service from the ServiceListBody
var FirstFakeService = services.Service{
Binary: "nova-scheduler",
DisabledReason: "test1",
Host: "host1",
ID: 1,
State: "up",
Status: "disabled",
UpdatedAt: time.Date(2012, 10, 29, 13, 42, 2, 0, time.UTC),
Zone: "internal",
}
// Second service from the ServiceListBody
var SecondFakeService = services.Service{
Binary: "nova-compute",
DisabledReason: "test2",
Host: "host1",
ID: 2,
State: "up",
Status: "disabled",
UpdatedAt: time.Date(2012, 10, 29, 13, 42, 5, 0, time.UTC),
Zone: "nova",
}
// Third service from the ServiceListBody
var ThirdFakeService = services.Service{
Binary: "nova-scheduler",
DisabledReason: "",
Host: "host2",
ID: 3,
State: "down",
Status: "enabled",
UpdatedAt: time.Date(2012, 9, 19, 6, 55, 34, 0, time.UTC),
Zone: "internal",
}
// Fourth service from the ServiceListBody
var FourthFakeService = services.Service{
Binary: "nova-compute",
DisabledReason: "test4",
Host: "host2",
ID: 4,
State: "down",
Status: "disabled",
UpdatedAt: time.Date(2012, 9, 18, 8, 3, 38, 0, time.UTC),
Zone: "nova",
}
// HandleListSuccessfully configures the test server to respond to a List request.
func HandleListSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/os-services", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, ServiceListBody)
})
}