mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
d7862c50b8
* first pass * add instance manager * fix tests * remove dead code * unexport fields * cleanup * remove ds instance from executor * cleanup * inline im * remove old func * get error working * unexport field * let fe do its magic * fix channel name * revert some tsdb changes * fix annotations * cleanup
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package cloudwatch
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTimeSeriesQuery(t *testing.T) {
|
|
executor := newExecutor(nil, nil, newTestConfig(), fakeSessionCache{})
|
|
now := time.Now()
|
|
|
|
t.Run("End time before start time should result in error", func(t *testing.T) {
|
|
_, err := executor.executeTimeSeriesQuery(context.TODO(), &backend.QueryDataRequest{Queries: []backend.DataQuery{{TimeRange: backend.TimeRange{
|
|
From: now.Add(time.Hour * -1),
|
|
To: now.Add(time.Hour * -2),
|
|
}}}})
|
|
assert.EqualError(t, err, "invalid time range: start time must be before end time")
|
|
})
|
|
|
|
t.Run("End time equals start time should result in error", func(t *testing.T) {
|
|
_, err := executor.executeTimeSeriesQuery(context.TODO(), &backend.QueryDataRequest{Queries: []backend.DataQuery{{TimeRange: backend.TimeRange{
|
|
From: now.Add(time.Hour * -1),
|
|
To: now.Add(time.Hour * -1),
|
|
}}}})
|
|
assert.EqualError(t, err, "invalid time range: start time must be before end time")
|
|
})
|
|
}
|