cloudwatch_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package cloudwatch
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/grafana/grafana/pkg/models"
  6. "github.com/grafana/grafana/pkg/tsdb"
  7. "github.com/grafana/grafana/pkg/components/simplejson"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestCloudWatch(t *testing.T) {
  11. Convey("CloudWatch", t, func() {
  12. Convey("executeQuery", func() {
  13. e := &CloudWatchExecutor{
  14. DataSource: &models.DataSource{
  15. JsonData: simplejson.New(),
  16. },
  17. }
  18. Convey("End time before start time should result in error", func() {
  19. _, err := e.executeQuery(context.Background(), &CloudWatchQuery{}, &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("now-1h", "now-2h")})
  20. So(err.Error(), ShouldEqual, "Invalid time range: Start time must be before end time")
  21. })
  22. Convey("End time equals start time should result in error", func() {
  23. _, err := e.executeQuery(context.Background(), &CloudWatchQuery{}, &tsdb.TsdbQuery{TimeRange: tsdb.NewTimeRange("now-1h", "now-1h")})
  24. So(err.Error(), ShouldEqual, "Invalid time range: Start time must be before end time")
  25. })
  26. })
  27. })
  28. }