blob: f0016bcb2699ed0b8efb2d07248c0bc4454f9991 [file] [log] [blame]
Jamie Hannaford5b7acc12015-02-13 09:14:25 +01001package flavors
2
Jamie Hannaford4a170282015-02-18 14:16:57 +01003import (
4 "fmt"
5 "testing"
6
7 "github.com/rackspace/gophercloud/testhelper/fixture"
8)
Jamie Hannaford5b7acc12015-02-13 09:14:25 +01009
Jamie Hannafordd3a78ef2015-02-18 12:17:16 +010010const 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
28var (
Jamie Hannaford8803f832015-02-23 10:44:55 +010029 flavorID = "{flavorID}"
Jamie Hannaford4a170282015-02-18 14:16:57 +010030 _baseURL = "/flavors"
Jamie Hannaford8803f832015-02-23 10:44:55 +010031 resURL = "/flavors/" + flavorID
Jamie Hannaford4a170282015-02-18 14:16:57 +010032)
33
34var (
Jamie Hannafordd3a78ef2015-02-18 12:17:16 +010035 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 Hannaford5b7acc12015-02-13 09:14:25 +010042)
Jamie Hannaford4a170282015-02-18 14:16:57 +010043
44func HandleList(t *testing.T) {
45 fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
46}
47
48func HandleGet(t *testing.T) {
49 fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
50}