27
27
func (s *configSuite) SetUpTest(c *gc.C) {
28
28
s.baseProviderSuite.SetUpTest(c)
29
s.PatchEnvironment("USER", "tester")
32
31
func minimalConfigValues() map[string]interface{} {
109
108
func (s *configSuite) TestNamespace(c *gc.C) {
110
109
testConfig := minimalConfig(c)
111
c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")
114
func (s *configSuite) TestNamespaceRootNoSudo(c *gc.C) {
115
restore := local.SetRootCheckFunction(func() bool { return true })
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")
123
func (s *configSuite) TestNamespaceRootWithSudo(c *gc.C) {
124
restore := local.SetRootCheckFunction(func() bool { return true })
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")
114
func (s *configSuite) TestBootstrapAsRoot(c *gc.C) {
115
restore := local.SetRootCheckFunction(func() bool { return true })
117
_, err := local.Provider.Prepare(minimalConfig(c))
118
c.Assert(err, gc.ErrorMatches, "bootstrapping a local environment must not be done as root")
135
121
type configRootSuite struct {