github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/extensions/services/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 "time" 8 9 "github.com/opentelekomcloud/gophertelekomcloud/openstack/evs/extensions/services" 10 11 th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" 12 "github.com/opentelekomcloud/gophertelekomcloud/testhelper/client" 13 ) 14 15 // ServiceListBody is sample response to the List call 16 const ServiceListBody = ` 17 { 18 "services": [{ 19 "status": "enabled", 20 "binary": "cinder-scheduler", 21 "zone": "nova", 22 "state": "up", 23 "updated_at": "2017-06-29T05:50:35.000000", 24 "host": "devstack", 25 "disabled_reason": null 26 }, 27 { 28 "status": "enabled", 29 "binary": "cinder-backup", 30 "zone": "nova", 31 "state": "up", 32 "updated_at": "2017-06-29T05:50:42.000000", 33 "host": "devstack", 34 "disabled_reason": null 35 }, 36 { 37 "status": "enabled", 38 "binary": "cinder-volume", 39 "zone": "nova", 40 "frozen": false, 41 "state": "up", 42 "updated_at": "2017-06-29T05:50:39.000000", 43 "cluster": null, 44 "host": "devstack@lvmdriver-1", 45 "replication_status": "disabled", 46 "active_backend_id": null, 47 "disabled_reason": null 48 }] 49 } 50 ` 51 52 // First service from the ServiceListBody 53 var FirstFakeService = services.Service{ 54 Binary: "cinder-scheduler", 55 DisabledReason: "", 56 Host: "devstack", 57 State: "up", 58 Status: "enabled", 59 UpdatedAt: time.Date(2017, 6, 29, 5, 50, 35, 0, time.UTC), 60 Zone: "nova", 61 } 62 63 // Second service from the ServiceListBody 64 var SecondFakeService = services.Service{ 65 Binary: "cinder-backup", 66 DisabledReason: "", 67 Host: "devstack", 68 State: "up", 69 Status: "enabled", 70 UpdatedAt: time.Date(2017, 6, 29, 5, 50, 42, 0, time.UTC), 71 Zone: "nova", 72 } 73 74 // Third service from the ServiceListBody 75 var ThirdFakeService = services.Service{ 76 ActiveBackendID: "", 77 Binary: "cinder-volume", 78 Cluster: "", 79 DisabledReason: "", 80 Frozen: false, 81 Host: "devstack@lvmdriver-1", 82 ReplicationStatus: "disabled", 83 State: "up", 84 Status: "enabled", 85 UpdatedAt: time.Date(2017, 6, 29, 5, 50, 39, 0, time.UTC), 86 Zone: "nova", 87 } 88 89 // HandleListSuccessfully configures the test server to respond to a List request. 90 func HandleListSuccessfully(t *testing.T) { 91 th.Mux.HandleFunc("/os-services", func(w http.ResponseWriter, r *http.Request) { 92 th.TestMethod(t, r, "GET") 93 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 94 95 w.Header().Add("Content-Type", "application/json") 96 _, _ = fmt.Fprint(w, ServiceListBody) 97 }) 98 }