github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/juju/osenv/vars_windows_test.go (about)

     1  package osenv_test
     2  
     3  import (
     4  	"os"
     5  
     6  	gc "launchpad.net/gocheck"
     7  
     8  	"launchpad.net/juju-core/juju/osenv"
     9  	"launchpad.net/juju-core/testing"
    10  )
    11  
    12  func (*importSuite) TestHome(c *gc.C) {
    13  	testbase.PatchEnvironment("HOMEPATH", "")
    14  	testbase.PatchEnvironment("HOMEDRIVE", "")
    15  
    16  	drive := "P:"
    17  	path := `\home\foo\bar`
    18  	h := drive + path
    19  	osenv.SetHome(h)
    20  	c.Check(os.Getenv("HOMEPATH"), gc.Equals, path)
    21  	c.Check(os.Getenv("HOMEDRIVE"), gc.Equals, drive)
    22  	c.Check(osenv.Home(), gc.Equals, h)
    23  
    24  	// now test that if we only set the path, we don't mess with the drive
    25  
    26  	path2 := `\home\someotherfoo\bar`
    27  
    28  	osenv.SetHome(path2)
    29  
    30  	c.Check(os.Getenv("HOMEPATH"), gc.Equals, path2)
    31  	c.Check(os.Getenv("HOMEDRIVE"), gc.Equals, drive)
    32  	c.Check(osenv.Home(), gc.Equals, drive+path2)
    33  }