Keith Byrne | bda4859 | 2016-03-23 11:37:08 +0000 | [diff] [blame^] | 1 | // +build fixtures |
| 2 | |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 3 | package flavors |
| 4 | |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 5 | import ( |
| 6 | "fmt" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/rackspace/gophercloud/testhelper/fixture" |
| 10 | ) |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 11 | |
Jamie Hannaford | d3a78ef | 2015-02-18 12:17:16 +0100 | [diff] [blame] | 12 | const 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 | |
| 30 | var ( |
Jamie Hannaford | 8803f83 | 2015-02-23 10:44:55 +0100 | [diff] [blame] | 31 | flavorID = "{flavorID}" |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 32 | _baseURL = "/flavors" |
Jamie Hannaford | 8803f83 | 2015-02-23 10:44:55 +0100 | [diff] [blame] | 33 | resURL = "/flavors/" + flavorID |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 34 | ) |
| 35 | |
| 36 | var ( |
Jamie Hannaford | d3a78ef | 2015-02-18 12:17:16 +0100 | [diff] [blame] | 37 | 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 Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 44 | ) |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 45 | |
| 46 | func HandleList(t *testing.T) { |
| 47 | fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200) |
| 48 | } |
| 49 | |
| 50 | func HandleGet(t *testing.T) { |
| 51 | fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200) |
| 52 | } |