1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
jc "github.com/juju/testing/checkers"
10
"github.com/juju/juju/apiserver/params"
13
func (s *serverSuite) TestGetBundleChangesBundleContentError(c *gc.C) {
14
args := params.GetBundleChangesParams{
17
r, err := s.client.GetBundleChanges(args)
18
c.Assert(err, gc.ErrorMatches, `cannot read bundle YAML: cannot unmarshal bundle data: yaml: did not find expected key`)
19
c.Assert(r, gc.DeepEquals, params.GetBundleChangesResults{})
22
func (s *serverSuite) TestGetBundleChangesBundleVerificationErrors(c *gc.C) {
23
args := params.GetBundleChangesParams{
34
r, err := s.client.GetBundleChanges(args)
35
c.Assert(err, jc.ErrorIsNil)
36
c.Assert(r.Changes, gc.IsNil)
37
c.Assert(r.Errors, jc.SameContents, []string{
38
`placement "1" refers to a machine not defined in this bundle`,
39
`too many units specified in unit placement for application "django"`,
40
`invalid charm URL in application "haproxy": URL has invalid charm or bundle name: "42"`,
41
`negative number of units specified on application "haproxy"`,
45
func (s *serverSuite) TestGetBundleChangesBundleConstraintsError(c *gc.C) {
46
args := params.GetBundleChangesParams{
55
r, err := s.client.GetBundleChanges(args)
56
c.Assert(err, jc.ErrorIsNil)
57
c.Assert(r.Changes, gc.IsNil)
58
c.Assert(r.Errors, jc.SameContents, []string{
59
`invalid constraints "bad=wolf" in application "django": unknown constraint "bad"`,
63
func (s *serverSuite) TestGetBundleChangesBundleStorageError(c *gc.C) {
64
args := params.GetBundleChangesParams{
74
r, err := s.client.GetBundleChanges(args)
75
c.Assert(err, jc.ErrorIsNil)
76
c.Assert(r.Changes, gc.IsNil)
77
c.Assert(r.Errors, jc.SameContents, []string{
78
`invalid storage "bad" in application "django": cannot parse count: count must be greater than zero, got "0"`,
82
func (s *serverSuite) TestGetBundleChangesSuccess(c *gc.C) {
83
args := params.GetBundleChangesParams{
93
charm: cs:trusty/haproxy-42
99
r, err := s.client.GetBundleChanges(args)
100
c.Assert(err, jc.ErrorIsNil)
101
c.Assert(r.Changes, jc.DeepEquals, []*params.BundleChangesChange{{
104
Args: []interface{}{"django", ""},
112
map[string]interface{}{"debug": true},
114
map[string]string{"tmpfs": "tmpfs,1G"},
118
Requires: []string{"addCharm-0"},
122
Args: []interface{}{"cs:trusty/haproxy-42", "trusty"},
130
map[string]interface{}{},
136
Requires: []string{"addCharm-2"},
139
Method: "addRelation",
140
Args: []interface{}{"$deploy-1:web", "$deploy-3:web"},
141
Requires: []string{"deploy-1", "deploy-3"},
143
c.Assert(r.Errors, gc.IsNil)
146
func (s *serverSuite) TestGetBundleChangesBundleEndpointBindingsSuccess(c *gc.C) {
147
args := params.GetBundleChangesParams{
157
r, err := s.client.GetBundleChanges(args)
158
c.Assert(err, jc.ErrorIsNil)
160
for _, change := range r.Changes {
161
if change.Method == "deploy" {
162
c.Assert(change, jc.DeepEquals, ¶ms.BundleChangesChange{
169
map[string]interface{}{},
172
map[string]string{"url": "public"},
175
Requires: []string{"addCharm-0"},