github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/juju/osenv/vars_linux_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Copyright 2014 Cloudbase Solutions SRL
     3  // Licensed under the AGPLv3, see LICENCE file for details.
     4  
     5  package osenv_test
     6  
     7  import (
     8  	"path/filepath"
     9  
    10  	gc "gopkg.in/check.v1"
    11  
    12  	"github.com/juju/juju/juju/osenv"
    13  )
    14  
    15  func (s *varsSuite) TestJujuXDGDataHome(c *gc.C) {
    16  	path := `/foo/bar/baz/`
    17  	// cleanup xdg config home because it has priority and it might
    18  	// be set on the testing env.
    19  	s.PatchEnvironment(osenv.XDGDataHome, "")
    20  	s.PatchEnvironment("HOME", path)
    21  	c.Assert(osenv.JujuXDGDataHomeLinux(), gc.Equals, filepath.Join(path, ".local", "share", "juju"))
    22  }
    23  
    24  func (s *varsSuite) TestJujuXDGDataHomeXDG(c *gc.C) {
    25  	testJujuXDGHome := "/a/bogus/home"
    26  	s.PatchEnvironment(osenv.XDGDataHome, testJujuXDGHome)
    27  	homeLinux := osenv.JujuXDGDataHomeLinux()
    28  	c.Assert(homeLinux, gc.Equals, filepath.Join(testJujuXDGHome, "juju"))
    29  }
    30  
    31  func (s *varsSuite) TestJujuXDGDataHomeNoXDGDefaultsConfig(c *gc.C) {
    32  	s.PatchEnvironment(osenv.XDGDataHome, "")
    33  	s.PatchEnvironment("HOME", "/a/bogus/user/home")
    34  	homeLinux := osenv.JujuXDGDataHomeLinux()
    35  	c.Assert(homeLinux, gc.Equals, "/a/bogus/user/home/.local/share/juju")
    36  }