mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* fix label handling * SEARCH() results could have multiple namespace, remove from legend * divide GetMetricStatistics related code * divide GetMetricData related code * divide parseGetMetricDataResponse() * divide parseGetMetricDataQuery() * divide test code * add test for GetMetricData * add test for GetMetricData parse response * fix bug of terminating gap * fix gofmt
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package cloudwatch
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/tsdb"
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestCloudWatch(t *testing.T) {
|
|
Convey("CloudWatch", t, func() {
|
|
|
|
Convey("executeQuery", func() {
|
|
e := &CloudWatchExecutor{
|
|
DataSource: &models.DataSource{
|
|
JsonData: simplejson.New(),
|
|
},
|
|
}
|
|
|
|
Convey("End time before start time should result in error", func() {
|
|
_, err := e.executeQuery(context.Background(), &CloudWatchQuery{}, &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 := e.executeQuery(context.Background(), &CloudWatchQuery{}, &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("now-1h", "now-1h")})
|
|
So(err.Error(), ShouldEqual, "Invalid time range: Start time must be before end time")
|
|
})
|
|
})
|
|
})
|
|
}
|