40
44
type localJujuTestSuite struct {
47
restoreRootCheck func()
48
oldUpstartLocation string
45
54
func (s *localJujuTestSuite) SetUpTest(c *gc.C) {
46
55
s.baseProviderSuite.SetUpTest(c)
56
// Construct the directories first.
57
err := local.CreateDirs(c, minimalConfig(c))
58
c.Assert(err, gc.IsNil)
59
s.oldUpstartLocation = local.SetUpstartScriptLocation(c.MkDir())
60
s.oldPath = os.Getenv("PATH")
61
s.testPath = c.MkDir()
62
os.Setenv("PATH", s.testPath+":"+s.oldPath)
64
// Add in an admin secret
65
s.Tests.TestConfig.Config["admin-secret"] = "sekrit"
66
s.restoreRootCheck = local.SetRootCheckFunction(func() bool { return true })
47
67
s.Tests.SetUpTest(c)
68
s.dbServiceName = "juju-db-" + local.ConfigNamespace(s.Env.Config())
50
71
func (s *localJujuTestSuite) TearDownTest(c *gc.C) {
51
// TODO(thumper): add the TearDownTest for s.Tests when destroy is implemented
52
// s.Tests.TearDownTest(c)
72
s.Tests.TearDownTest(c)
73
os.Setenv("PATH", s.oldPath)
75
local.SetUpstartScriptLocation(s.oldUpstartLocation)
53
76
s.baseProviderSuite.TearDownTest(c)
79
func (s *localJujuTestSuite) MakeTool(c *gc.C, name, script string) {
80
path := filepath.Join(s.testPath, name)
81
script = "#!/bin/bash\n" + script
82
err := ioutil.WriteFile(path, []byte(script), 0755)
83
c.Assert(err, gc.IsNil)
86
func (s *localJujuTestSuite) StoppedStatus(c *gc.C) {
87
s.MakeTool(c, "status", `echo "some-service stop/waiting"`)
90
func (s *localJujuTestSuite) RunningStatus(c *gc.C) {
91
s.MakeTool(c, "status", `echo "some-service start/running, process 123"`)
56
94
var _ = gc.Suite(&localJujuTestSuite{
57
95
Tests: jujutest.Tests{
58
96
TestConfig: jujutest.TestConfig{minimalConfigValues()},