~mfoord/juju-core/tests-replset

« back to all changes in this revision

Viewing changes to state/apiserver/api_test.go

  • Committer: Benji York
  • Date: 2013-03-15 15:20:42 UTC
  • mfrom: (993.3.9 1130151)
  • Revision ID: benji.york@canonical.com-20130315152042-kn87kj7tqtkqozuq
Add ServiceDestroyUnits to the API

R=fwereade, dimitern, rog
CC=
https://codereview.appspot.com/7554046

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        "launchpad.net/juju-core/state/api"
13
13
        "launchpad.net/juju-core/state/api/params"
14
14
        "launchpad.net/juju-core/state/apiserver"
 
15
        "launchpad.net/juju-core/state/statecmd"
15
16
        coretesting "launchpad.net/juju-core/testing"
16
17
        "net"
17
18
        stdtesting "testing"
122
123
        op:    opClientSetAnnotation,
123
124
        allow: []string{"user-admin", "user-other"},
124
125
}, {
125
 
        about: "Client.ServiceAddUnits",
126
 
        op:    opClientServiceAddUnits,
 
126
        about: "Client.AddServiceUnits",
 
127
        op:    opClientAddServiceUnits,
 
128
        allow: []string{"user-admin", "user-other"},
 
129
}, {
 
130
        about: "Client.DestroyServiceUnits",
 
131
        op:    opClientDestroyServiceUnits,
127
132
        allow: []string{"user-admin", "user-other"},
128
133
}, {
129
134
        about: "Client.ServiceDestroy",
387
392
        }, nil
388
393
}
389
394
 
390
 
func opClientServiceAddUnits(c *C, st *api.State, mst *state.State) (func(), error) {
 
395
func opClientAddServiceUnits(c *C, st *api.State, mst *state.State) (func(), error) {
391
396
        // This test only checks that the call is made without error, ensuring the
392
397
        // signatures match.
393
 
        err := st.Client().ServiceAddUnits("wordpress", 1)
 
398
        err := st.Client().AddServiceUnits("wordpress", 1)
394
399
        if err != nil {
395
400
                return func() {}, err
396
401
        }
398
403
        return func() {}, nil
399
404
}
400
405
 
 
406
func opClientDestroyServiceUnits(c *C, st *api.State, mst *state.State) (func(), error) {
 
407
        err := statecmd.AddServiceUnits(mst, params.AddServiceUnits{"wordpress", 1})
 
408
        if err != nil {
 
409
                return func() {}, err
 
410
        }
 
411
        newUnitName := []string{"wordpress/1"}
 
412
        err = st.Client().DestroyServiceUnits(newUnitName)
 
413
        if err != nil {
 
414
                return func() {
 
415
                        _ = statecmd.DestroyServiceUnits(mst, params.DestroyServiceUnits{newUnitName})
 
416
                }, err
 
417
        }
 
418
        c.Assert(err, IsNil)
 
419
        return func() {}, err
 
420
}
 
421
 
401
422
func opClientServiceDestroy(c *C, st *api.State, mst *state.State) (func(), error) {
402
423
        // This test only checks that the call is made without error, ensuring the
403
424
        // signatures match.