1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package simplestreams_test
9
jc "github.com/juju/testing/checkers"
10
gc "gopkg.in/check.v1"
12
"github.com/juju/juju/environs/simplestreams"
15
type jsonSuite struct{}
17
func (s *jsonSuite) TestItemCollectionMarshalling(c *gc.C) {
18
// Ensure that unmarshalling a simplestreams.ItemCollection
19
// directly (not through ParseCloudMetadata) doesn't
20
// cause any surprises.
21
var m simplestreams.ItemCollection
22
m.Items = make(map[string]interface{})
23
err := json.Unmarshal([]byte(`{
29
c.Assert(err, jc.ErrorIsNil)
30
c.Assert(m.Items, gc.DeepEquals, map[string]interface{}{
34
// Ensure marshalling works as expected, too.
35
b, err := json.Marshal(&m)
36
c.Assert(err, jc.ErrorIsNil)
37
c.Assert(string(b), gc.Equals, `{"items":{"a":"b","c":123}}`)