~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/manual/provider_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        })
34
34
}
35
35
 
 
36
func (s *providerSuite) TestPrepareForCreateEnvironment(c *gc.C) {
 
37
        testConfig, err := config.New(config.UseDefaults, manual.MinimalConfigValues())
 
38
        c.Assert(err, jc.ErrorIsNil)
 
39
        cfg, err := manual.ProviderInstance.PrepareForCreateEnvironment(testConfig)
 
40
        c.Assert(err, jc.ErrorIsNil)
 
41
        c.Assert(cfg, gc.Equals, testConfig)
 
42
}
 
43
 
36
44
func (s *providerSuite) TestPrepareForBootstrapCloudEndpointAndRegion(c *gc.C) {
37
45
        ctx, err := s.testPrepareForBootstrap(c, "endpoint", "region")
38
46
        c.Assert(err, jc.ErrorIsNil)
53
61
 
54
62
func (s *providerSuite) testPrepareForBootstrap(c *gc.C, endpoint, region string) (environs.BootstrapContext, error) {
55
63
        minimal := manual.MinimalConfigValues()
56
 
        minimal["use-sshstorage"] = true
57
64
        testConfig, err := config.New(config.UseDefaults, minimal)
58
65
        c.Assert(err, jc.ErrorIsNil)
59
 
        ctx := envtesting.BootstrapContext(c)
60
 
        _, err = manual.ProviderInstance.PrepareForBootstrap(ctx, environs.PrepareForBootstrapParams{
 
66
        testConfig, err = manual.ProviderInstance.BootstrapConfig(environs.BootstrapConfigParams{
61
67
                Config:        testConfig,
62
68
                CloudEndpoint: endpoint,
63
69
                CloudRegion:   region,
64
70
        })
 
71
        if err != nil {
 
72
                return nil, err
 
73
        }
 
74
        ctx := envtesting.BootstrapContext(c)
 
75
        _, err = manual.ProviderInstance.PrepareForBootstrap(ctx, testConfig)
65
76
        return ctx, err
66
77
}
67
78
 
68
 
func (s *providerSuite) TestPrepareUseSSHStorage(c *gc.C) {
69
 
        minimal := manual.MinimalConfigValues()
70
 
        minimal["use-sshstorage"] = false
71
 
        testConfig, err := config.New(config.UseDefaults, minimal)
72
 
        c.Assert(err, jc.ErrorIsNil)
73
 
        _, err = manual.ProviderInstance.PrepareForBootstrap(envtesting.BootstrapContext(c), environs.PrepareForBootstrapParams{
74
 
                Config:        testConfig,
75
 
                CloudEndpoint: "hostname",
76
 
        })
77
 
        c.Assert(err, gc.ErrorMatches, "use-sshstorage must not be specified")
78
 
 
79
 
        minimal["use-sshstorage"] = true
80
 
        testConfig, err = config.New(config.UseDefaults, minimal)
81
 
        c.Assert(err, jc.ErrorIsNil)
82
 
        _, err = manual.ProviderInstance.PrepareForBootstrap(envtesting.BootstrapContext(c), environs.PrepareForBootstrapParams{
83
 
                Config:        testConfig,
84
 
                CloudEndpoint: "hostname",
85
 
        })
86
 
        c.Assert(err, jc.ErrorIsNil)
87
 
}
88
 
 
89
 
func (s *providerSuite) TestPrepareSetsUseSSHStorage(c *gc.C) {
90
 
        attrs := manual.MinimalConfigValues()
91
 
        delete(attrs, "use-sshstorage")
92
 
        testConfig, err := config.New(config.UseDefaults, attrs)
93
 
        c.Assert(err, jc.ErrorIsNil)
94
 
 
95
 
        env, err := manual.ProviderInstance.PrepareForBootstrap(envtesting.BootstrapContext(c), environs.PrepareForBootstrapParams{
96
 
                Config:        testConfig,
97
 
                CloudEndpoint: "hostname",
98
 
        })
99
 
        c.Assert(err, jc.ErrorIsNil)
100
 
        cfg := env.Config()
101
 
        value := cfg.AllAttrs()["use-sshstorage"]
102
 
        c.Assert(value, jc.IsTrue)
103
 
}
104
 
 
105
 
func (s *providerSuite) TestOpenDoesntSetUseSSHStorage(c *gc.C) {
106
 
        attrs := manual.MinimalConfigValues()
107
 
        delete(attrs, "use-sshstorage")
108
 
        testConfig, err := config.New(config.UseDefaults, attrs)
109
 
        c.Assert(err, jc.ErrorIsNil)
110
 
 
111
 
        env, err := manual.ProviderInstance.Open(testConfig)
112
 
        c.Assert(err, jc.ErrorIsNil)
113
 
        cfg := env.Config()
114
 
        _, ok := cfg.AllAttrs()["use-sshstorage"]
115
 
        c.Assert(ok, jc.IsFalse)
116
 
        ok = manual.EnvironUseSSHStorage(env)
117
 
        c.Assert(ok, jc.IsFalse)
118
 
}
119
 
 
120
79
func (s *providerSuite) TestNullAlias(c *gc.C) {
121
80
        p, err := environs.Provider("manual")
122
81
        c.Assert(p, gc.NotNil)