forked from juju/utils
/
home_windows_test.go
42 lines (30 loc) · 920 Bytes
/
home_windows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2011, 2012, 2013 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package utils_test
import (
"os"
"github.com/juju/testing"
gc "launchpad.net/gocheck"
"github.com/juju/utils"
)
type homeSuite struct {
testing.IsolationSuite
}
var _ = gc.Suite(&homeSuite{})
func (s *homeSuite) TestHome(c *gc.C) {
s.PatchEnvironment("HOMEPATH", "")
s.PatchEnvironment("HOMEDRIVE", "")
drive := "P:"
path := `\home\foo\bar`
h := drive + path
utils.SetHome(h)
c.Check(os.Getenv("HOMEPATH"), gc.Equals, path)
c.Check(os.Getenv("HOMEDRIVE"), gc.Equals, drive)
c.Check(utils.Home(), gc.Equals, h)
// now test that if we only set the path, we don't mess with the drive
path2 := `\home\someotherfoo\bar`
utils.SetHome(path2)
c.Check(os.Getenv("HOMEPATH"), gc.Equals, path2)
c.Check(os.Getenv("HOMEDRIVE"), gc.Equals, drive)
c.Check(utils.Home(), gc.Equals, drive+path2)
}