func (c *DestroyServiceCommand) Run(_ *cmd.Context) error {
	conn, err := juju.NewConnFromName(c.EnvName)
	if err != nil {
		return err
	}
	defer conn.Close()

	params := params.ServiceDestroy{
		ServiceName: c.ServiceName,
	}
	return statecmd.ServiceDestroy(conn.State, params)
}
func (s *DestroySuite) TestServiceDestroy(c *C) {
	charm := s.AddTestingCharm(c, "dummy")
	svc, err := s.State.AddService("dummy-service", charm)
	c.Assert(err, IsNil)
	c.Assert(svc.Life(), Equals, state.Alive)
	c.Logf("Svc: %+v", svc)

	for i, t := range serviceDestroyTests {
		c.Logf("test %d. %s", i, t.about)
		err = statecmd.ServiceDestroy(s.State, params.ServiceDestroy{
			ServiceName: t.service,
		})
		if t.err != "" {
			c.Assert(err, ErrorMatches, t.err)
		} else {
			c.Assert(err, IsNil)
		}
	}
}
Beispiel #3
0
// ServiceDestroy destroys a given service.
func (c *Client) ServiceDestroy(args params.ServiceDestroy) error {
	return statecmd.ServiceDestroy(c.api.state, args)
}