-
Notifications
You must be signed in to change notification settings - Fork 508
/
Copy pathbootstrapconfig_test.go
64 lines (52 loc) · 2.15 KB
/
bootstrapconfig_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package jujuclient_test
import (
"os"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/internal/testing"
"github.com/juju/juju/jujuclient"
)
type BootstrapConfigSuite struct {
testing.FakeJujuXDGDataHomeSuite
store jujuclient.BootstrapConfigStore
}
var _ = gc.Suite(&BootstrapConfigSuite{})
func (s *BootstrapConfigSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
s.store = jujuclient.NewFileClientStore()
writeTestBootstrapConfigFile(c)
}
func (s *BootstrapConfigSuite) TestBootstrapConfigForControllerNoFile(c *gc.C) {
err := os.Remove(jujuclient.JujuBootstrapConfigPath())
c.Assert(err, jc.ErrorIsNil)
details, err := s.store.BootstrapConfigForController("not-found")
c.Assert(err, gc.ErrorMatches, "bootstrap config for controller not-found not found")
c.Assert(details, gc.IsNil)
}
func (s *BootstrapConfigSuite) TestBootstrapConfigForControllerNotFound(c *gc.C) {
details, err := s.store.BootstrapConfigForController("not-found")
c.Assert(err, gc.ErrorMatches, "bootstrap config for controller not-found not found")
c.Assert(details, gc.IsNil)
}
func (s *BootstrapConfigSuite) TestBootstrapConfigForController(c *gc.C) {
cfg, err := s.store.BootstrapConfigForController("aws-test")
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg, gc.NotNil)
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["aws-test"])
}
func (s *BootstrapConfigSuite) TestUpdateBootstrapConfigNewController(c *gc.C) {
err := s.store.UpdateBootstrapConfig("new-controller", testBootstrapConfig["mallards"])
c.Assert(err, jc.ErrorIsNil)
cfg, err := s.store.BootstrapConfigForController("new-controller")
c.Assert(err, jc.ErrorIsNil)
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["mallards"])
}
func (s *BootstrapConfigSuite) TestUpdateBootstrapConfigOverwrites(c *gc.C) {
err := s.store.UpdateBootstrapConfig("aws-test", testBootstrapConfig["mallards"])
c.Assert(err, jc.ErrorIsNil)
cfg, err := s.store.BootstrapConfigForController("aws-test")
c.Assert(err, jc.ErrorIsNil)
c.Assert(*cfg, jc.DeepEquals, testBootstrapConfig["mallards"])
}