~ubuntu-branches/ubuntu/wily/juju-core/wily

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/agent/format-1.16_whitebox_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-28 16:53:15 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20140228165315-g8n1ds0jrtekhxq6
Tags: 1.17.4-0ubuntu1
* New upstream point release (LP: #1261628):
  - https://launchpad.net/juju-core/trunk/1.17.4
  - d/control: Prefer juju-mongodb over mongodb-server for juju-local
    package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
package agent
9
9
 
10
10
import (
 
11
        "io/ioutil"
11
12
        "os"
12
13
        "path"
 
14
        "path/filepath"
13
15
 
14
16
        gc "launchpad.net/gocheck"
15
17
 
16
18
        "launchpad.net/juju-core/juju/osenv"
17
19
        jc "launchpad.net/juju-core/testing/checkers"
18
20
        "launchpad.net/juju-core/testing/testbase"
 
21
        "launchpad.net/juju-core/version"
19
22
)
20
23
 
21
24
type format_1_16Suite struct {
48
51
        c.Assert(formatContent, gc.Equals, format_1_16)
49
52
}
50
53
 
 
54
var configDataWithoutUpgradedToVersion = `
 
55
tag: omg
 
56
nonce: a nonce
 
57
cacert: Y2EgY2VydA==
 
58
stateaddresses:
 
59
- localhost:1234
 
60
apiaddresses:
 
61
- localhost:1235
 
62
oldpassword: sekrit
 
63
values: {}
 
64
`
 
65
 
 
66
func (s *format_1_16Suite) TestMissingUpgradedToVersion(c *gc.C) {
 
67
        dataDir := c.MkDir()
 
68
        err := ioutil.WriteFile(filepath.Join(dataDir, "agent.conf"), []byte(configDataWithoutUpgradedToVersion), 0600)
 
69
        c.Assert(err, gc.IsNil)
 
70
        readConfig, err := s.formatter.read(dataDir)
 
71
        c.Assert(err, gc.IsNil)
 
72
        c.Assert(readConfig.UpgradedToVersion(), gc.Equals, version.MustParse("1.16.0"))
 
73
}
 
74
 
51
75
func (s *format_1_16Suite) assertWriteAndRead(c *gc.C, config *configInternal) {
52
76
        err := s.formatter.write(config)
53
77
        c.Assert(err, gc.IsNil)
56
80
        c.Assert(err, gc.IsNil)
57
81
        c.Assert(readConfig.dataDir, gc.Equals, "")
58
82
        // This is put in by the ReadConf method that we are avoiding using
59
 
        // becuase it will have side-effects soon around migrating configs.
 
83
        // because it will have side-effects soon around migrating configs.
60
84
        readConfig.dataDir = config.dataDir
61
85
        c.Assert(readConfig, gc.DeepEquals, config)
62
86
}