1
1
// Copyright 2013 Canonical Ltd.
2
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
9
gc "launchpad.net/gocheck"
11
"launchpad.net/juju-core/environs/config"
11
"launchpad.net/juju-core/juju/osenv"
14
14
type JujuHomeSuite struct {
20
20
func (s *JujuHomeSuite) TestStandardHome(c *gc.C) {
21
21
testJujuHome := c.MkDir()
22
defer config.SetJujuHome(config.SetJujuHome(testJujuHome))
23
c.Assert(config.JujuHome(), gc.Equals, testJujuHome)
22
defer osenv.SetJujuHome(osenv.SetJujuHome(testJujuHome))
23
c.Assert(osenv.JujuHome(), gc.Equals, testJujuHome)
26
26
func (s *JujuHomeSuite) TestErrorHome(c *gc.C) {
27
27
// Invalid juju home leads to panic when retrieving.
28
f := func() { _ = config.JujuHome() }
28
f := func() { _ = osenv.JujuHome() }
29
29
c.Assert(f, gc.PanicMatches, "juju home hasn't been initialized")
30
f = func() { _ = config.JujuHomePath("environments.yaml") }
30
f = func() { _ = osenv.JujuHomePath("environments.yaml") }
31
31
c.Assert(f, gc.PanicMatches, "juju home hasn't been initialized")
34
34
func (s *JujuHomeSuite) TestHomePath(c *gc.C) {
35
35
testJujuHome := c.MkDir()
36
defer config.SetJujuHome(config.SetJujuHome(testJujuHome))
37
envPath := config.JujuHomePath("environments.yaml")
36
defer osenv.SetJujuHome(osenv.SetJujuHome(testJujuHome))
37
envPath := osenv.JujuHomePath("environments.yaml")
38
38
c.Assert(envPath, gc.Equals, filepath.Join(testJujuHome, "environments.yaml"))