61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
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{
|
|
Bounds: [2]int64{0, 100},
|
|
},
|
|
"y": chronograf.Axis{
|
|
Bounds: [2]int64{0, 100},
|
|
},
|
|
"y2": chronograf.Axis{
|
|
Bounds: [2]int64{0, 100},
|
|
},
|
|
},
|
|
},
|
|
false,
|
|
},
|
|
{
|
|
"invalid axes present",
|
|
&chronograf.DashboardCell{
|
|
Axes: map[string]chronograf.Axis{
|
|
"axis of evil": chronograf.Axis{
|
|
Bounds: [2]int64{666, 666},
|
|
},
|
|
"axis of awesome": chronograf.Axis{
|
|
Bounds: [2]int64{1337, 31337},
|
|
},
|
|
},
|
|
},
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
}
|