~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/controller/destroy_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
        "gopkg.in/juju/names.v2"
16
16
 
17
17
        "github.com/juju/juju/api/base"
 
18
        apicontroller "github.com/juju/juju/api/controller"
18
19
        "github.com/juju/juju/apiserver/params"
19
20
        "github.com/juju/juju/cmd/juju/controller"
20
21
        "github.com/juju/juju/cmd/modelcmd"
54
55
// fakeDestroyAPI mocks out the controller API
55
56
type fakeDestroyAPI struct {
56
57
        gitjujutesting.Stub
57
 
        cloud      environs.CloudSpec
58
 
        env        map[string]interface{}
59
 
        destroyAll bool
60
 
        blocks     []params.ModelBlockInfo
61
 
        envStatus  map[string]base.ModelStatus
62
 
        allModels  []base.UserModel
 
58
        cloud        environs.CloudSpec
 
59
        env          map[string]interface{}
 
60
        destroyAll   bool
 
61
        blocks       []params.ModelBlockInfo
 
62
        envStatus    map[string]base.ModelStatus
 
63
        allModels    []base.UserModel
 
64
        hostedConfig []apicontroller.HostedConfig
63
65
}
64
66
 
65
67
func (f *fakeDestroyAPI) Close() error {
83
85
        return f.env, nil
84
86
}
85
87
 
 
88
func (f *fakeDestroyAPI) HostedModelConfigs() ([]apicontroller.HostedConfig, error) {
 
89
        f.MethodCall(f, "HostedModelConfigs")
 
90
        if err := f.NextErr(); err != nil {
 
91
                return nil, err
 
92
        }
 
93
        return f.hostedConfig, nil
 
94
}
 
95
 
86
96
func (f *fakeDestroyAPI) DestroyController(destroyAll bool) error {
87
97
        f.MethodCall(f, "DestroyController", destroyAll)
88
98
        f.destroyAll = destroyAll
213
223
                })
214
224
                s.api.envStatus[model.modelUUID] = base.ModelStatus{
215
225
                        UUID:               uuid,
216
 
                        Life:               params.Dead,
 
226
                        Life:               string(params.Dead),
217
227
                        HostedMachineCount: 0,
218
228
                        ServiceCount:       0,
219
229
                        Owner:              owner.Canonical(),
317
327
 
318
328
func (s *DestroySuite) TestDestroyControllerAliveModels(c *gc.C) {
319
329
        for uuid, status := range s.api.envStatus {
320
 
                status.Life = params.Alive
 
330
                status.Life = string(params.Alive)
321
331
                s.api.envStatus[uuid] = status
322
332
        }
323
333
        s.api.SetErrors(&params.Error{Code: params.CodeHasHostedModels})