d40b66f1c1
* Calculate min period based on time range and no of queries * Use hardcoded array of periods if period is not defined actively by the user * Fix broken tests * Use a smaller max period for auto interval * Fix broken tests * Test period calculation * Test min retention period * Fix broken test
29 lines
911 B
Go
29 lines
911 B
Go
package cloudwatch
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestTimeSeriesQuery(t *testing.T) {
|
|
Convey("TestTimeSeriesQuery", t, func() {
|
|
executor := &CloudWatchExecutor{}
|
|
|
|
Convey("Time range is valid", func() {
|
|
Convey("End time before start time should result in error", func() {
|
|
_, err := executor.executeTimeSeriesQuery(context.TODO(), &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("now-1h", "now-2h")})
|
|
So(err.Error(), ShouldEqual, "Invalid time range: Start time must be before end time")
|
|
})
|
|
|
|
Convey("End time equals start time should result in error", func() {
|
|
_, err := executor.executeTimeSeriesQuery(context.TODO(), &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("now-1h", "now-1h")})
|
|
So(err.Error(), ShouldEqual, "Invalid time range: Start time must be before end time")
|
|
})
|
|
})
|
|
})
|
|
}
|