~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/provider/local/config_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-03 09:22:46 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20140203092246-e03vg402vztzo4qa
Tags: 1.17.2-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
func (s *configSuite) SetUpTest(c *gc.C) {
28
28
        s.baseProviderSuite.SetUpTest(c)
29
 
        s.PatchEnvironment("USER", "tester")
30
29
}
31
30
 
32
31
func minimalConfigValues() map[string]interface{} {
108
107
 
109
108
func (s *configSuite) TestNamespace(c *gc.C) {
110
109
        testConfig := minimalConfig(c)
111
 
        c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")
112
 
}
113
 
 
114
 
func (s *configSuite) TestNamespaceRootNoSudo(c *gc.C) {
115
 
        restore := local.SetRootCheckFunction(func() bool { return true })
116
 
        defer restore()
117
 
        err := os.Setenv("USER", "root")
118
 
        c.Assert(err, gc.IsNil)
119
 
        testConfig := minimalConfig(c)
120
 
        c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "root-test")
121
 
}
122
 
 
123
 
func (s *configSuite) TestNamespaceRootWithSudo(c *gc.C) {
124
 
        restore := local.SetRootCheckFunction(func() bool { return true })
125
 
        defer restore()
126
 
        err := os.Setenv("USER", "root")
127
 
        c.Assert(err, gc.IsNil)
128
 
        err = os.Setenv("SUDO_USER", "tester")
129
 
        c.Assert(err, gc.IsNil)
130
 
        defer os.Setenv("SUDO_USER", "")
131
 
        testConfig := minimalConfig(c)
132
 
        c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")
 
110
        s.PatchEnvironment("USER", "tester")
 
111
        c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")
 
112
}
 
113
 
 
114
func (s *configSuite) TestBootstrapAsRoot(c *gc.C) {
 
115
        restore := local.SetRootCheckFunction(func() bool { return true })
 
116
        defer restore()
 
117
        _, err := local.Provider.Prepare(minimalConfig(c))
 
118
        c.Assert(err, gc.ErrorMatches, "bootstrapping a local environment must not be done as root")
133
119
}
134
120
 
135
121
type configRootSuite struct {