func (s *varsSuite) TestJujuXDGDataHome(c *gc.C) { path := `/foo/bar/baz/` // cleanup xdg config home because it has priority and it might // be set on the testing env. s.PatchEnvironment(osenv.XDGDataHome, "") s.PatchEnvironment("HOME", path) c.Assert(osenv.JujuXDGDataHomeLinux(), gc.Equals, filepath.Join(path, ".local", "share", "juju")) }
func (s *varsSuite) TestBlankJujuXDGDataHomeEnvVar(c *gc.C) { s.PatchEnvironment(osenv.JujuXDGDataHomeEnvKey, "") if runtime.GOOS == "windows" { s.PatchEnvironment("APPDATA", `P:\foobar`) } else { s.PatchEnvironment("HOME", "/foobar") } c.Assert(osenv.JujuXDGDataHomeDir(), gc.Not(gc.Equals), "") if runtime.GOOS == "windows" { c.Assert(osenv.JujuXDGDataHomeDir(), gc.Equals, osenv.JujuXDGDataHomeWin()) } else { c.Assert(osenv.JujuXDGDataHomeDir(), gc.Equals, osenv.JujuXDGDataHomeLinux()) } }
func (s *varsSuite) TestJujuXDGDataHomeNoXDGDefaultsConfig(c *gc.C) { s.PatchEnvironment(osenv.XDGDataHome, "") s.PatchEnvironment("HOME", "/a/bogus/user/home") homeLinux := osenv.JujuXDGDataHomeLinux() c.Assert(homeLinux, gc.Equals, "/a/bogus/user/home/.local/share/juju") }
func (s *varsSuite) TestJujuXDGDataHomeXDG(c *gc.C) { testJujuXDGHome := "/a/bogus/home" s.PatchEnvironment(osenv.XDGDataHome, testJujuXDGHome) homeLinux := osenv.JujuXDGDataHomeLinux() c.Assert(homeLinux, gc.Equals, filepath.Join(testJujuXDGHome, "juju")) }