config parse_test check for string coercion in client.meta

This commit is contained in:
Lang Martin 2019-06-10 12:46:21 -04:00
parent 6742ef5d73
commit 28cf8eddfe
3 changed files with 10 additions and 12 deletions

View file

@ -478,12 +478,10 @@ func TestConfig_ParsePanic(t *testing.T) {
// structure should not be unexpected // structure should not be unexpected
func TestConfig_ParseSliceExtra(t *testing.T) { func TestConfig_ParseSliceExtra(t *testing.T) {
c, err := ParseConfigFile("./testdata/config-slices.json") c, err := ParseConfigFile("./testdata/config-slices.json")
if err != nil { require.NoError(t, err)
t.Fatalf("parse error: %s\n", err)
}
opt := map[string]string{"o0": "foo", "o1": "bar"} opt := map[string]string{"o0": "foo", "o1": "bar"}
meta := map[string]string{"m0": "foo", "m1": "bar"} meta := map[string]string{"m0": "foo", "m1": "bar", "m2": "true", "m3": "1.2"}
env := map[string]string{"e0": "baz"} env := map[string]string{"e0": "baz"}
srv := []string{"foo", "bar"} srv := []string{"foo", "bar"}
@ -497,9 +495,7 @@ func TestConfig_ParseSliceExtra(t *testing.T) {
// the alt format is also accepted by hcl as valid config data // the alt format is also accepted by hcl as valid config data
c, err = ParseConfigFile("./testdata/config-slices-alt.json") c, err = ParseConfigFile("./testdata/config-slices-alt.json")
if err != nil { require.NoError(t, err)
t.Fatalf("parse error: %s\n", err)
}
require.EqualValues(t, opt, c.Client.Options) require.EqualValues(t, opt, c.Client.Options)
require.EqualValues(t, meta, c.Client.Meta) require.EqualValues(t, meta, c.Client.Meta)
@ -511,9 +507,7 @@ func TestConfig_ParseSliceExtra(t *testing.T) {
// small files keep more extra keys than large ones // small files keep more extra keys than large ones
_, err = ParseConfigFile("./testdata/obj-len-one-server.json") _, err = ParseConfigFile("./testdata/obj-len-one-server.json")
if err != nil { require.NoError(t, err)
t.Fatalf("parse error: %s\n", err)
}
} }
var sample0 = &Config{ var sample0 = &Config{

View file

@ -9,7 +9,9 @@
"meta": [ "meta": [
{ {
"m0": "foo", "m0": "foo",
"m1": "bar" "m1": "bar",
"m2": true,
"m3": 1.2
} }
], ],
"options": [ "options": [

View file

@ -6,7 +6,9 @@
}, },
"meta": { "meta": {
"m0": "foo", "m0": "foo",
"m1": "bar" "m1": "bar",
"m2": true,
"m3": 1.2
}, },
"chroot_env": { "chroot_env": {
"e0": "baz" "e0": "baz"