fix(pkger): add monotoneX geom type to valid geometries

pull/17321/head^2
Johnny Steenbergen 2020-04-13 12:36:34 -07:00 committed by Johnny Steenbergen
parent d16406650b
commit 217eddc87e
2 changed files with 44 additions and 5 deletions

View File

@ -2753,10 +2753,11 @@ func validPosition(pos string) []validationErr {
}
var geometryTypes = map[string]bool{
"line": true,
"step": true,
"stacked": true,
"bar": true,
"line": true,
"step": true,
"stacked": true,
"monotoneX": true,
"bar": true,
}
func validGeometry(geom string) []validationErr {

View File

@ -2528,7 +2528,7 @@ spec:
{
name: "invalid geom flag",
validationErrs: 1,
valFields: []string{fieldSpec, "charts[0].geom"},
valFields: []string{fieldSpec, fieldDashCharts, fieldChartGeom},
pkgStr: `apiVersion: influxdata.com/v2alpha1
kind: Dashboard
metadata:
@ -4188,6 +4188,44 @@ func Test_PkgValidationErr(t *testing.T) {
assert.Equal(t, "chart kind must be provided", errs[1].Reason)
}
func Test_validGeometry(t *testing.T) {
tests := []struct {
geom string
expected bool
}{
{
geom: "line", expected: true,
},
{
geom: "step", expected: true,
},
{
geom: "stacked", expected: true,
},
{
geom: "monotoneX", expected: true,
},
{
geom: "bar", expected: true,
},
{
geom: "rando", expected: false,
},
{
geom: "not a valid geom", expected: false,
},
}
for _, tt := range tests {
fn := func(t *testing.T) {
isValid := len(validGeometry(tt.geom)) == 0
assert.Equal(t, tt.expected, isValid)
}
t.Run(tt.geom, fn)
}
}
type testPkgResourceError struct {
name string
encoding Encoding