Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 1 | package flavors |
| 2 | |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 3 | import ( |
| 4 | "fmt" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/rackspace/gophercloud/testhelper/fixture" |
| 8 | ) |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 9 | |
Jamie Hannaford | d3a78ef | 2015-02-18 12:17:16 +0100 | [diff] [blame] | 10 | const flavor = ` |
| 11 | { |
| 12 | "id": %d, |
| 13 | "links": [ |
| 14 | { |
| 15 | "href": "https://openstack.example.com/v1.0/1234/flavors/%d", |
| 16 | "rel": "self" |
| 17 | }, |
| 18 | { |
| 19 | "href": "https://openstack.example.com/flavors/%d", |
| 20 | "rel": "bookmark" |
| 21 | } |
| 22 | ], |
| 23 | "name": "%s", |
| 24 | "ram": %d |
| 25 | } |
| 26 | ` |
| 27 | |
| 28 | var ( |
Jamie Hannaford | 8803f83 | 2015-02-23 10:44:55 +0100 | [diff] [blame] | 29 | flavorID = "{flavorID}" |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 30 | _baseURL = "/flavors" |
Jamie Hannaford | 8803f83 | 2015-02-23 10:44:55 +0100 | [diff] [blame] | 31 | resURL = "/flavors/" + flavorID |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 32 | ) |
| 33 | |
| 34 | var ( |
Jamie Hannaford | d3a78ef | 2015-02-18 12:17:16 +0100 | [diff] [blame] | 35 | flavor1 = fmt.Sprintf(flavor, 1, 1, 1, "m1.tiny", 512) |
| 36 | flavor2 = fmt.Sprintf(flavor, 2, 2, 2, "m1.small", 1024) |
| 37 | flavor3 = fmt.Sprintf(flavor, 3, 3, 3, "m1.medium", 2048) |
| 38 | flavor4 = fmt.Sprintf(flavor, 4, 4, 4, "m1.large", 4096) |
| 39 | |
| 40 | listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4) |
| 41 | getFlavorResp = fmt.Sprintf(`{"flavor": %s}`, flavor1) |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 42 | ) |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 43 | |
| 44 | func HandleList(t *testing.T) { |
| 45 | fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200) |
| 46 | } |
| 47 | |
| 48 | func HandleGet(t *testing.T) { |
| 49 | fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200) |
| 50 | } |