blob: 98393241e1b5a0dfd1ce1d6a0cbf7fbd882a15b0 [file] [log] [blame]
Keith Byrnebda48592016-03-23 11:37:08 +00001// +build fixtures
2
Jamie Hannaford5b7acc12015-02-13 09:14:25 +01003package flavors
4
Jamie Hannaford4a170282015-02-18 14:16:57 +01005import (
6 "fmt"
7 "testing"
8
9 "github.com/rackspace/gophercloud/testhelper/fixture"
10)
Jamie Hannaford5b7acc12015-02-13 09:14:25 +010011
Jamie Hannafordd3a78ef2015-02-18 12:17:16 +010012const flavor = `
13{
14 "id": %d,
15 "links": [
16 {
17 "href": "https://openstack.example.com/v1.0/1234/flavors/%d",
18 "rel": "self"
19 },
20 {
21 "href": "https://openstack.example.com/flavors/%d",
22 "rel": "bookmark"
23 }
24 ],
25 "name": "%s",
26 "ram": %d
27}
28`
29
30var (
Jamie Hannaford8803f832015-02-23 10:44:55 +010031 flavorID = "{flavorID}"
Jamie Hannaford4a170282015-02-18 14:16:57 +010032 _baseURL = "/flavors"
Jamie Hannaford8803f832015-02-23 10:44:55 +010033 resURL = "/flavors/" + flavorID
Jamie Hannaford4a170282015-02-18 14:16:57 +010034)
35
36var (
Jamie Hannafordd3a78ef2015-02-18 12:17:16 +010037 flavor1 = fmt.Sprintf(flavor, 1, 1, 1, "m1.tiny", 512)
38 flavor2 = fmt.Sprintf(flavor, 2, 2, 2, "m1.small", 1024)
39 flavor3 = fmt.Sprintf(flavor, 3, 3, 3, "m1.medium", 2048)
40 flavor4 = fmt.Sprintf(flavor, 4, 4, 4, "m1.large", 4096)
41
42 listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4)
43 getFlavorResp = fmt.Sprintf(`{"flavor": %s}`, flavor1)
Jamie Hannaford5b7acc12015-02-13 09:14:25 +010044)
Jamie Hannaford4a170282015-02-18 14:16:57 +010045
46func HandleList(t *testing.T) {
47 fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
48}
49
50func HandleGet(t *testing.T) {
51 fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
52}