alerting_test.go 794 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package sqlstore
  2. import (
  3. "testing"
  4. m "github.com/grafana/grafana/pkg/models"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestAlertingDataAccess(t *testing.T) {
  8. Convey("Testing Alerting data access", t, func() {
  9. InitTestDB(t)
  10. Convey("Can create alert", func() {
  11. items := []m.Alert{
  12. {
  13. PanelId: 1,
  14. DashboardId: 1,
  15. Query: "Query",
  16. QueryRefId: "A",
  17. WarnLevel: 30,
  18. ErrorLevel: 50,
  19. Interval: 10,
  20. Title: "Alerting title",
  21. Description: "Alerting description",
  22. QueryRange: "5m",
  23. Aggregator: "avg",
  24. },
  25. }
  26. cmd := m.SaveAlertsCommand{
  27. Alerts: &items,
  28. DashboardId: 1,
  29. OrgId: 1,
  30. UserId: 1,
  31. }
  32. err := SaveAlerts(&cmd)
  33. So(err, ShouldBeNil)
  34. })
  35. })
  36. }