gopkg.in/docker/libcompose.v0@v0.4.0/integration/rm_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 6 . "gopkg.in/check.v1" 7 ) 8 9 func (s *CliSuite) TestDelete(c *C) { 10 p := s.ProjectFromText(c, "up", SimpleTemplate) 11 12 name := fmt.Sprintf("%s_%s_1", p, "hello") 13 14 cn := s.GetContainerByName(c, name) 15 c.Assert(cn, NotNil) 16 c.Assert(cn.State.Running, Equals, true) 17 18 s.FromText(c, p, "stop", SimpleTemplate) 19 s.FromText(c, p, "rm", "--force", SimpleTemplate) 20 21 cn = s.GetContainerByName(c, name) 22 c.Assert(cn, IsNil) 23 } 24 25 func (s *CliSuite) TestDeleteOnlyRemovesStopped(c *C) { 26 projectTemplate := ` 27 hello: 28 image: busybox 29 stdin_open: true 30 tty: true 31 bye: 32 image: busybox 33 stdin_open: true 34 tty: true 35 ` 36 37 p := s.ProjectFromText(c, "up", projectTemplate) 38 39 helloName := fmt.Sprintf("%s_%s_1", p, "hello") 40 byeName := fmt.Sprintf("%s_%s_1", p, "bye") 41 42 helloContainer := s.GetContainerByName(c, helloName) 43 c.Assert(helloContainer, NotNil) 44 c.Assert(helloContainer.State.Running, Equals, true) 45 46 byeContainer := s.GetContainerByName(c, byeName) 47 c.Assert(byeContainer, NotNil) 48 c.Assert(byeContainer.State.Running, Equals, true) 49 50 s.FromText(c, p, "stop", "bye", projectTemplate) 51 52 byeContainer = s.GetContainerByName(c, byeName) 53 c.Assert(byeContainer, NotNil) 54 c.Assert(byeContainer.State.Running, Equals, false) 55 56 s.FromText(c, p, "rm", "--force", projectTemplate) 57 58 byeContainer = s.GetContainerByName(c, byeName) 59 c.Assert(byeContainer, IsNil) 60 61 helloContainer = s.GetContainerByName(c, helloName) 62 c.Assert(helloContainer, NotNil) 63 } 64 65 func (s *CliSuite) TestDeleteWithVol(c *C) { 66 p := s.ProjectFromText(c, "up", SimpleTemplate) 67 68 name := fmt.Sprintf("%s_%s_1", p, "hello") 69 70 cn := s.GetContainerByName(c, name) 71 c.Assert(cn, NotNil) 72 c.Assert(cn.State.Running, Equals, true) 73 74 s.FromText(c, p, "stop", SimpleTemplate) 75 s.FromText(c, p, "rm", "--force", "-v", SimpleTemplate) 76 77 cn = s.GetContainerByName(c, name) 78 c.Assert(cn, IsNil) 79 }