LEFT | RIGHT |
1 package params_test | 1 package params_test |
2 | 2 |
3 import ( | 3 import ( |
4 "encoding/json" | 4 "encoding/json" |
5 . "launchpad.net/gocheck" | 5 . "launchpad.net/gocheck" |
6 "launchpad.net/juju-core/charm" | 6 "launchpad.net/juju-core/charm" |
7 "launchpad.net/juju-core/constraints" | 7 "launchpad.net/juju-core/constraints" |
| 8 "launchpad.net/juju-core/state" |
8 "launchpad.net/juju-core/state/api/params" | 9 "launchpad.net/juju-core/state/api/params" |
9 "testing" | 10 "testing" |
10 ) | 11 ) |
11 | 12 |
12 // TestPackage integrates the tests into gotest. | 13 // TestPackage integrates the tests into gotest. |
13 func TestPackage(t *testing.T) { | 14 func TestPackage(t *testing.T) { |
14 TestingT(t) | 15 TestingT(t) |
15 } | 16 } |
16 | 17 |
17 type MarshalSuite struct{} | 18 type MarshalSuite struct{} |
(...skipping 17 matching lines...) Expand all Loading... |
35 }, | 36 }, |
36 }, | 37 }, |
37 json: `["machine","change",{"Id":"Benji","InstanceId":"Shazam","Status":
"error","StatusInfo":"foo"}]`, | 38 json: `["machine","change",{"Id":"Benji","InstanceId":"Shazam","Status":
"error","StatusInfo":"foo"}]`, |
38 }, { | 39 }, { |
39 about: "ServiceInfo Delta", | 40 about: "ServiceInfo Delta", |
40 value: params.Delta{ | 41 value: params.Delta{ |
41 Entity: ¶ms.ServiceInfo{ | 42 Entity: ¶ms.ServiceInfo{ |
42 Name: "Benji", | 43 Name: "Benji", |
43 Exposed: true, | 44 Exposed: true, |
44 CharmURL: "cs:series/name", | 45 CharmURL: "cs:series/name", |
45 » » » Life: "dying", | 46 » » » Life: state.Dying.String(), |
46 Constraints: constraints.MustParse("arch=arm mem=1024M")
, | 47 Constraints: constraints.MustParse("arch=arm mem=1024M")
, |
47 Config: map[string]interface{}{ | 48 Config: map[string]interface{}{ |
48 "hello": "goodbye", | 49 "hello": "goodbye", |
49 "foo": false, | 50 "foo": false, |
50 }, | 51 }, |
51 }, | 52 }, |
52 }, | 53 }, |
53 json: `["service","change",{"CharmURL": "cs:series/name","Name":"Benji",
"Exposed":true,"Life":"dying","Constraints":{"arch":"arm", "mem": 1024},"Config"
: {"hello":"goodbye","foo":false}}]`, | 54 json: `["service","change",{"CharmURL": "cs:series/name","Name":"Benji",
"Exposed":true,"Life":"dying","Constraints":{"arch":"arm", "mem": 1024},"Config"
: {"hello":"goodbye","foo":false}}]`, |
54 }, { | 55 }, { |
55 about: "UnitInfo Delta", | 56 about: "UnitInfo Delta", |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 142 |
142 func (s *MarshalSuite) TestDeltaMarshalJSONUnknownOperation(c *C) { | 143 func (s *MarshalSuite) TestDeltaMarshalJSONUnknownOperation(c *C) { |
143 err := json.Unmarshal([]byte(`["relation","masticate",{}]`), new(params.
Delta)) | 144 err := json.Unmarshal([]byte(`["relation","masticate",{}]`), new(params.
Delta)) |
144 c.Check(err, ErrorMatches, `Unexpected operation "masticate"`) | 145 c.Check(err, ErrorMatches, `Unexpected operation "masticate"`) |
145 } | 146 } |
146 | 147 |
147 func (s *MarshalSuite) TestDeltaMarshalJSONUnknownEntity(c *C) { | 148 func (s *MarshalSuite) TestDeltaMarshalJSONUnknownEntity(c *C) { |
148 err := json.Unmarshal([]byte(`["qwan","change",{}]`), new(params.Delta)) | 149 err := json.Unmarshal([]byte(`["qwan","change",{}]`), new(params.Delta)) |
149 c.Check(err, ErrorMatches, `Unexpected entity name "qwan"`) | 150 c.Check(err, ErrorMatches, `Unexpected entity name "qwan"`) |
150 } | 151 } |
LEFT | RIGHT |