~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/cmd/juju/destroyenvironment_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-03 09:22:46 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20140203092246-e03vg402vztzo4qa
Tags: 1.17.2-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        c.Assert(err, jc.Satisfies, errors.IsNotFoundError)
45
45
}
46
46
 
 
47
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEFlag(c *gc.C) {
 
48
        // Prepare the environment so we can destroy it.
 
49
        _, err := environs.PrepareFromName("dummyenv", s.ConfigStore)
 
50
        c.Assert(err, gc.IsNil)
 
51
 
 
52
        // check that either environment or the flag is mandatory
 
53
        opc, errc := runCommand(nullContext(), new(DestroyEnvironmentCommand))
 
54
        c.Check(<-errc, gc.Equals, NoEnvironmentError)
 
55
 
 
56
        // We don't allow them to supply both entries at the same time
 
57
        opc, errc = runCommand(nullContext(), new(DestroyEnvironmentCommand), "-e", "dummyenv", "dummyenv", "--yes")
 
58
        c.Check(<-errc, gc.Equals, DoubleEnvironmentError)
 
59
        // We treat --environment the same way
 
60
        opc, errc = runCommand(nullContext(), new(DestroyEnvironmentCommand), "--environment", "dummyenv", "dummyenv", "--yes")
 
61
        c.Check(<-errc, gc.Equals, DoubleEnvironmentError)
 
62
 
 
63
        // destroy using the -e flag
 
64
        opc, errc = runCommand(nullContext(), new(DestroyEnvironmentCommand), "-e", "dummyenv", "--yes")
 
65
        c.Check(<-errc, gc.IsNil)
 
66
        c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
 
67
 
 
68
        // Verify that the environment information has been removed.
 
69
        _, err = s.ConfigStore.ReadInfo("dummyenv")
 
70
        c.Assert(err, jc.Satisfies, errors.IsNotFoundError)
 
71
}
 
72
 
47
73
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandBroken(c *gc.C) {
48
74
        oldinfo, err := s.ConfigStore.ReadInfo("dummyenv")
49
75
        c.Assert(err, gc.IsNil)