44
44
c.Assert(err, jc.Satisfies, errors.IsNotFoundError)
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)
52
// check that either environment or the flag is mandatory
53
opc, errc := runCommand(nullContext(), new(DestroyEnvironmentCommand))
54
c.Check(<-errc, gc.Equals, NoEnvironmentError)
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)
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")
68
// Verify that the environment information has been removed.
69
_, err = s.ConfigStore.ReadInfo("dummyenv")
70
c.Assert(err, jc.Satisfies, errors.IsNotFoundError)
47
73
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandBroken(c *gc.C) {
48
74
oldinfo, err := s.ConfigStore.ReadInfo("dummyenv")
49
75
c.Assert(err, gc.IsNil)