2017-07-21 16:09:49 +00:00
|
|
|
package server_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/influxdata/chronograf"
|
|
|
|
"github.com/influxdata/chronograf/server"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Cells_CorrectAxis(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
axisTests := []struct {
|
|
|
|
name string
|
|
|
|
cell *chronograf.DashboardCell
|
|
|
|
shouldFail bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"correct axes",
|
|
|
|
&chronograf.DashboardCell{
|
|
|
|
Axes: map[string]chronograf.Axis{
|
|
|
|
"x": chronograf.Axis{
|
2017-07-26 19:45:17 +00:00
|
|
|
Bounds: []string{"0", "100"},
|
2017-07-21 16:09:49 +00:00
|
|
|
},
|
|
|
|
"y": chronograf.Axis{
|
2017-07-26 19:45:17 +00:00
|
|
|
Bounds: []string{"0", "100"},
|
2017-07-21 16:09:49 +00:00
|
|
|
},
|
|
|
|
"y2": chronograf.Axis{
|
2017-07-26 19:45:17 +00:00
|
|
|
Bounds: []string{"0", "100"},
|
2017-07-21 16:09:49 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"invalid axes present",
|
|
|
|
&chronograf.DashboardCell{
|
|
|
|
Axes: map[string]chronograf.Axis{
|
|
|
|
"axis of evil": chronograf.Axis{
|
2017-07-26 19:45:17 +00:00
|
|
|
Bounds: []string{"666", "666"},
|
2017-07-21 16:09:49 +00:00
|
|
|
},
|
|
|
|
"axis of awesome": chronograf.Axis{
|
2017-07-26 19:45:17 +00:00
|
|
|
Bounds: []string{"1337", "31337"},
|
2017-07-21 16:09:49 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range axisTests {
|
|
|
|
t.Run(test.name, func(tt *testing.T) {
|
|
|
|
if err := server.HasCorrectAxes(test.cell); err != nil && !test.shouldFail {
|
|
|
|
t.Errorf("%q: Unexpected error: err: %s", test.name, err)
|
|
|
|
} else if err == nil && test.shouldFail {
|
|
|
|
t.Errorf("%q: Expected error and received none", test.name)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|