forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.go
97 lines (89 loc) · 2.6 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
package testing
import (
"fmt"
"net/http"
"testing"
"time"
"github.com/chjlangzi/gophercloud/openstack/blockstorage/extensions/services"
th "github.com/chjlangzi/gophercloud/testhelper"
"github.com/chjlangzi/gophercloud/testhelper/client"
)
// ServiceListBody is sample response to the List call
const ServiceListBody = `
{
"services": [{
"status": "enabled",
"binary": "cinder-scheduler",
"zone": "nova",
"state": "up",
"updated_at": "2017-06-29T05:50:35.000000",
"host": "devstack",
"disabled_reason": null
},
{
"status": "enabled",
"binary": "cinder-backup",
"zone": "nova",
"state": "up",
"updated_at": "2017-06-29T05:50:42.000000",
"host": "devstack",
"disabled_reason": null
},
{
"status": "enabled",
"binary": "cinder-volume",
"zone": "nova",
"frozen": false,
"state": "up",
"updated_at": "2017-06-29T05:50:39.000000",
"cluster": null,
"host": "devstack@lvmdriver-1",
"replication_status": "disabled",
"active_backend_id": null,
"disabled_reason": null
}]
}
`
// First service from the ServiceListBody
var FirstFakeService = services.Service{
Binary: "cinder-scheduler",
DisabledReason: "",
Host: "devstack",
State: "up",
Status: "enabled",
UpdatedAt: time.Date(2017, 6, 29, 5, 50, 35, 0, time.UTC),
Zone: "nova",
}
// Second service from the ServiceListBody
var SecondFakeService = services.Service{
Binary: "cinder-backup",
DisabledReason: "",
Host: "devstack",
State: "up",
Status: "enabled",
UpdatedAt: time.Date(2017, 6, 29, 5, 50, 42, 0, time.UTC),
Zone: "nova",
}
// Third service from the ServiceListBody
var ThirdFakeService = services.Service{
ActiveBackendID: "",
Binary: "cinder-volume",
Cluster: "",
DisabledReason: "",
Frozen: false,
Host: "devstack@lvmdriver-1",
ReplicationStatus: "disabled",
State: "up",
Status: "enabled",
UpdatedAt: time.Date(2017, 6, 29, 5, 50, 39, 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)
})
}