1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package jujuclient_test
9
jc "github.com/juju/testing/checkers"
10
gc "gopkg.in/check.v1"
12
"github.com/juju/juju/jujuclient"
13
"github.com/juju/juju/testing"
16
type BootstrapConfigSuite struct {
17
testing.FakeJujuXDGDataHomeSuite
18
store jujuclient.BootstrapConfigStore
21
var _ = gc.Suite(&BootstrapConfigSuite{})
23
func (s *BootstrapConfigSuite) SetUpTest(c *gc.C) {
24
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
25
s.store = jujuclient.NewFileClientStore()
26
writeTestBootstrapConfigFile(c)
29
func (s *BootstrapConfigSuite) TestBootstrapConfigForControllerNoFile(c *gc.C) {
30
err := os.Remove(jujuclient.JujuBootstrapConfigPath())
31
c.Assert(err, jc.ErrorIsNil)
32
details, err := s.store.BootstrapConfigForController("not-found")
33
c.Assert(err, gc.ErrorMatches, "bootstrap config for controller not-found not found")
34
c.Assert(details, gc.IsNil)
37
func (s *BootstrapConfigSuite) TestBootstrapConfigForControllerNotFound(c *gc.C) {
38
details, err := s.store.BootstrapConfigForController("not-found")
39
c.Assert(err, gc.ErrorMatches, "bootstrap config for controller not-found not found")
40
c.Assert(details, gc.IsNil)
43
func (s *BootstrapConfigSuite) TestBootstrapConfigForController(c *gc.C) {
44
cfg, err := s.store.BootstrapConfigForController("aws-test")
45
c.Assert(err, jc.ErrorIsNil)
46
c.Assert(cfg, gc.NotNil)
47
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["aws-test"])
50
func (s *BootstrapConfigSuite) TestUpdateBootstrapConfigNewController(c *gc.C) {
51
err := s.store.UpdateBootstrapConfig("new-controller", testBootstrapConfig["mallards"])
52
c.Assert(err, jc.ErrorIsNil)
53
cfg, err := s.store.BootstrapConfigForController("new-controller")
54
c.Assert(err, jc.ErrorIsNil)
55
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["mallards"])
58
func (s *BootstrapConfigSuite) TestUpdateBootstrapConfigOverwrites(c *gc.C) {
59
err := s.store.UpdateBootstrapConfig("aws-test", testBootstrapConfig["mallards"])
60
c.Assert(err, jc.ErrorIsNil)
61
cfg, err := s.store.BootstrapConfigForController("aws-test")
62
c.Assert(err, jc.ErrorIsNil)
63
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["mallards"])