db: fix flavor id parsing (#197)
* Flavor IDs returned with instances are always strings
* Flavor IDs returned with flavors are integers or null, there is a
str_id parameter that contains the ID in string format
diff --git a/openstack/db/v1/flavors/testing/fixtures.go b/openstack/db/v1/flavors/testing/fixtures.go
index b2b2d5f..9c323b8 100644
--- a/openstack/db/v1/flavors/testing/fixtures.go
+++ b/openstack/db/v1/flavors/testing/fixtures.go
@@ -9,19 +9,20 @@
const flavor = `
{
- "id": %d,
+ "id": %s,
"links": [
{
- "href": "https://openstack.example.com/v1.0/1234/flavors/%d",
+ "href": "https://openstack.example.com/v1.0/1234/flavors/%s",
"rel": "self"
},
{
- "href": "https://openstack.example.com/flavors/%d",
+ "href": "https://openstack.example.com/flavors/%s",
"rel": "bookmark"
}
],
"name": "%s",
- "ram": %d
+ "ram": %d,
+ "str_id": "%s"
}
`
@@ -32,12 +33,13 @@
)
var (
- flavor1 = fmt.Sprintf(flavor, 1, 1, 1, "m1.tiny", 512)
- flavor2 = fmt.Sprintf(flavor, 2, 2, 2, "m1.small", 1024)
- flavor3 = fmt.Sprintf(flavor, 3, 3, 3, "m1.medium", 2048)
- flavor4 = fmt.Sprintf(flavor, 4, 4, 4, "m1.large", 4096)
+ flavor1 = fmt.Sprintf(flavor, "1", "1", "1", "m1.tiny", 512, "1")
+ flavor2 = fmt.Sprintf(flavor, "2", "2", "2", "m1.small", 1024, "2")
+ flavor3 = fmt.Sprintf(flavor, "3", "3", "3", "m1.medium", 2048, "3")
+ flavor4 = fmt.Sprintf(flavor, "4", "4", "4", "m1.large", 4096, "4")
+ flavor5 = fmt.Sprintf(flavor, "null", "d1", "d1", "ds512M", 512, "d1")
- listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4)
+ listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4, flavor5)
getFlavorResp = fmt.Sprintf(`{"flavor": %s}`, flavor1)
)