func (s *initSystemSuite) TestInstallCommandsShutdown(c *gc.C) { name := "juju-shutdown-job" conf, err := service.ShutdownAfterConf("cloud-final") c.Assert(err, jc.ErrorIsNil) svc, err := systemd.NewService(name, conf, s.dataDir) c.Assert(err, jc.ErrorIsNil) commands, err := svc.InstallCommands() c.Assert(err, jc.ErrorIsNil) test := systemdtesting.WriteConfTest{ Service: name, DataDir: s.dataDir, Expected: ` [Unit] Description=juju shutdown job After=syslog.target After=network.target After=systemd-user-sessions.service After=cloud-final [Service] ExecStart=/sbin/shutdown -h now ExecStopPost=/bin/systemctl disable juju-shutdown-job.service [Install] WantedBy=multi-user.target `[1:], } test.CheckCommands(c, commands) }
func (*agentSuite) TestShutdownAfterConf(c *gc.C) { conf, err := service.ShutdownAfterConf("spam") c.Assert(err, jc.ErrorIsNil) c.Check(conf, jc.DeepEquals, common.Conf{ Desc: "juju shutdown job", Transient: true, AfterStopped: "spam", ExecStart: "/sbin/shutdown -h now", }) renderer := &shell.BashRenderer{} c.Check(conf.Validate(renderer), jc.ErrorIsNil) }
func (*agentSuite) TestShutdownAfterConfMissingServiceName(c *gc.C) { _, err := service.ShutdownAfterConf("") c.Check(err, gc.ErrorMatches, `.*missing "after" service name.*`) }