5
. "launchpad.net/gocheck"
6
"launchpad.net/goose/nova"
9
type JsonSuite struct {
12
var _ = Suite(&JsonSuite{})
14
func (s *JsonSuite) SetUpSuite(c *C) {
15
nova.UseNumericIds(true)
18
func (s *JsonSuite) assertMarshallRoundtrip(c *C, value interface{}, unmarshalled interface{}) {
19
data, err := json.Marshal(value)
23
err = json.Unmarshal(data, &unmarshalled)
27
c.Assert(unmarshalled, DeepEquals, value)
30
// The following tests all check that unmarshalling of Ids with values > 1E6
33
func (s *JsonSuite) TestMarshallEntityLargeIntId(c *C) {
34
entity := nova.Entity{Id: "2000000", Name: "test"}
35
var unmarshalled nova.Entity
36
s.assertMarshallRoundtrip(c, &entity, &unmarshalled)
39
func (s *JsonSuite) TestMarshallFlavorDetailLargeIntId(c *C) {
40
fd := nova.FlavorDetail{Id: "2000000", Name: "test"}
41
var unmarshalled nova.FlavorDetail
42
s.assertMarshallRoundtrip(c, &fd, &unmarshalled)
45
func (s *JsonSuite) TestMarshallServerDetailLargeIntId(c *C) {
46
fd := nova.Entity{Id: "2000000", Name: "test"}
47
im := nova.Entity{Id: "2000000", Name: "test"}
48
sd := nova.ServerDetail{Id: "2000000", Name: "test", Flavor: fd, Image: im}
49
var unmarshalled nova.ServerDetail
50
s.assertMarshallRoundtrip(c, &sd, &unmarshalled)
53
func (s *JsonSuite) TestMarshallFloatingIPLargeIntId(c *C) {
55
fip := nova.FloatingIP{Id: 2000000, InstanceId: &id}
56
var unmarshalled nova.FloatingIP
57
s.assertMarshallRoundtrip(c, &fip, &unmarshalled)