~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/jujuclient/bootstrapconfig_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2016 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package jujuclient_test
 
5
 
 
6
import (
 
7
        "os"
 
8
 
 
9
        jc "github.com/juju/testing/checkers"
 
10
        gc "gopkg.in/check.v1"
 
11
 
 
12
        "github.com/juju/juju/jujuclient"
 
13
        "github.com/juju/juju/testing"
 
14
)
 
15
 
 
16
type BootstrapConfigSuite struct {
 
17
        testing.FakeJujuXDGDataHomeSuite
 
18
        store jujuclient.BootstrapConfigStore
 
19
}
 
20
 
 
21
var _ = gc.Suite(&BootstrapConfigSuite{})
 
22
 
 
23
func (s *BootstrapConfigSuite) SetUpTest(c *gc.C) {
 
24
        s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
 
25
        s.store = jujuclient.NewFileClientStore()
 
26
        writeTestBootstrapConfigFile(c)
 
27
}
 
28
 
 
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)
 
35
}
 
36
 
 
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)
 
41
}
 
42
 
 
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"])
 
48
}
 
49
 
 
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"])
 
56
}
 
57
 
 
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"])
 
64
}