~go-bot/juju-core/trunk

« back to all changes in this revision

Viewing changes to provider/manual/config_test.go

[r=wallyworld],[bug=1302205] Force manual storage-port to int

The manual provider storage-port config
attribute needs to have a schema definition
of ForceInt so it can be deserialised from
state correctly.

https://codereview.appspot.com/85750045/

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        c.Assert(unknownAttrs["bootstrap-host"], gc.Equals, "hostname")
73
73
        c.Assert(unknownAttrs["bootstrap-user"], gc.Equals, "")
74
74
        c.Assert(unknownAttrs["storage-listen-ip"], gc.Equals, "")
75
 
        c.Assert(unknownAttrs["storage-port"], gc.Equals, int64(8040))
 
75
        c.Assert(unknownAttrs["storage-port"], gc.Equals, int(8040))
76
76
}
77
77
 
78
78
func (s *configSuite) TestConfigMutability(c *gc.C) {
89
89
                "bootstrap-host":    "new-hostname",
90
90
                "bootstrap-user":    "new-username",
91
91
                "storage-listen-ip": "10.0.0.123",
92
 
                "storage-port":      int64(1234),
 
92
                "storage-port":      1234,
93
93
        } {
94
94
                testConfig = MinimalConfig(c)
95
95
                testConfig, err = testConfig.Apply(map[string]interface{}{k: v})
119
119
        c.Assert(testConfig.storageAddr(), gc.Equals, "hostname:8040")
120
120
        c.Assert(testConfig.storageListenAddr(), gc.Equals, ":8040")
121
121
        values["storage-listen-ip"] = "10.0.0.123"
122
 
        values["storage-port"] = int64(1234)
 
122
        values["storage-port"] = 1234
123
123
        testConfig = getEnvironConfig(c, values)
124
124
        c.Assert(testConfig.storageAddr(), gc.Equals, "hostname:1234")
125
125
        c.Assert(testConfig.storageListenAddr(), gc.Equals, "10.0.0.123:1234")
137
137
        c.Assert(err, gc.IsNil)
138
138
        c.Assert(envConfig.useSSHStorage(), jc.IsFalse)
139
139
}
 
140
 
 
141
func (s *configSuite) TestValidateConfigWithFloatPort(c *gc.C) {
 
142
        // When the config values get serialized through JSON, the integers
 
143
        // get coerced to float64 values.  The parsing needs to handle this.
 
144
        values := MinimalConfigValues()
 
145
        values["storage-port"] = float64(8040)
 
146
        cfg, err := config.New(config.UseDefaults, values)
 
147
        c.Assert(err, gc.IsNil)
 
148
        valid, err := ProviderInstance.Validate(cfg, nil)
 
149
        c.Assert(err, gc.IsNil)
 
150
        unknownAttrs := valid.UnknownAttrs()
 
151
        c.Assert(unknownAttrs["storage-port"], gc.Equals, int(8040))
 
152
}