~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/environ_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:
11
11
 
12
12
        gc "launchpad.net/gocheck"
13
13
 
 
14
        coreCloudinit "launchpad.net/juju-core/cloudinit"
14
15
        "launchpad.net/juju-core/constraints"
15
16
        "launchpad.net/juju-core/environs"
 
17
        "launchpad.net/juju-core/environs/cloudinit"
16
18
        "launchpad.net/juju-core/environs/config"
17
19
        "launchpad.net/juju-core/environs/jujutest"
18
20
        envtesting "launchpad.net/juju-core/environs/testing"
19
21
        "launchpad.net/juju-core/environs/tools"
20
22
        "launchpad.net/juju-core/instance"
21
23
        "launchpad.net/juju-core/provider/local"
 
24
        coretesting "launchpad.net/juju-core/testing"
22
25
        jc "launchpad.net/juju-core/testing/checkers"
23
26
)
24
27
 
96
99
        // Construct the directories first.
97
100
        err := local.CreateDirs(c, minimalConfig(c))
98
101
        c.Assert(err, gc.IsNil)
99
 
        s.oldUpstartLocation = local.SetUpstartScriptLocation(c.MkDir())
100
102
        s.oldPath = os.Getenv("PATH")
101
103
        s.testPath = c.MkDir()
102
104
        os.Setenv("PATH", s.testPath+":"+s.oldPath)
103
105
 
104
106
        // Add in an admin secret
105
107
        s.Tests.TestConfig["admin-secret"] = "sekrit"
106
 
        s.restoreRootCheck = local.SetRootCheckFunction(func() bool { return true })
 
108
        s.restoreRootCheck = local.SetRootCheckFunction(func() bool { return false })
107
109
        s.Tests.SetUpTest(c)
108
110
 
109
111
        cfg, err := config.New(config.NoDefaults, s.TestConfig)
115
117
        s.Tests.TearDownTest(c)
116
118
        os.Setenv("PATH", s.oldPath)
117
119
        s.restoreRootCheck()
118
 
        local.SetUpstartScriptLocation(s.oldUpstartLocation)
119
120
        s.baseProviderSuite.TearDownTest(c)
120
121
}
121
122
 
141
142
})
142
143
 
143
144
func (s *localJujuTestSuite) TestBootstrap(c *gc.C) {
144
 
        c.Skip("Cannot test bootstrap at this stage.")
 
145
        s.PatchValue(local.FinishBootstrap, func(mcfg *cloudinit.MachineConfig, cloudcfg *coreCloudinit.Config, ctx environs.BootstrapContext) error {
 
146
                c.Assert(cloudcfg.AptUpdate(), jc.IsFalse)
 
147
                c.Assert(cloudcfg.AptUpgrade(), jc.IsFalse)
 
148
                c.Assert(cloudcfg.Packages(), gc.HasLen, 0)
 
149
                return nil
 
150
        })
 
151
        testConfig := minimalConfig(c)
 
152
        environ, err := local.Provider.Prepare(testConfig)
 
153
        c.Assert(err, gc.IsNil)
 
154
        envtesting.UploadFakeTools(c, environ.Storage())
 
155
        defer environ.Storage().RemoveAll()
 
156
        ctx := envtesting.NewBootstrapContext(coretesting.Context(c))
 
157
        err = environ.Bootstrap(ctx, constraints.Value{})
 
158
        c.Assert(err, gc.IsNil)
145
159
}
146
160
 
147
161
func (s *localJujuTestSuite) TestStartStop(c *gc.C) {