(t *testing.T)
| 1488 | } |
| 1489 | |
| 1490 | func TestAlert(t *testing.T) { |
| 1491 | ctx := context.Background() |
| 1492 | repo := makeRepo(t, map[string]string{ |
| 1493 | `rill.yaml`: ``, |
| 1494 | // model m1 |
| 1495 | `models/m1.sql`: `SELECT 1`, |
| 1496 | `alerts/a1.yaml`: ` |
| 1497 | type: alert |
| 1498 | display_name: My Alert |
| 1499 | |
| 1500 | refs: |
| 1501 | - model/m1 |
| 1502 | |
| 1503 | refresh: |
| 1504 | ref_update: true |
| 1505 | cron: '0 * * * *' |
| 1506 | |
| 1507 | watermark: inherit |
| 1508 | |
| 1509 | intervals: |
| 1510 | duration: PT1H |
| 1511 | limit: 10 |
| 1512 | |
| 1513 | query: |
| 1514 | name: MetricsViewToplist |
| 1515 | args: |
| 1516 | metrics_view: mv1 |
| 1517 | for: |
| 1518 | user_email: benjamin@example.com |
| 1519 | |
| 1520 | on_recover: true |
| 1521 | renotify: true |
| 1522 | renotify_after: 24h |
| 1523 | |
| 1524 | notify: |
| 1525 | email: |
| 1526 | recipients: |
| 1527 | - benjamin@example.com |
| 1528 | |
| 1529 | annotations: |
| 1530 | foo: bar |
| 1531 | `, |
| 1532 | }) |
| 1533 | |
| 1534 | resources := []*Resource{ |
| 1535 | { |
| 1536 | Name: ResourceName{Kind: ResourceKindModel, Name: "m1"}, |
| 1537 | Paths: []string{"/models/m1.sql"}, |
| 1538 | ModelSpec: &runtimev1.ModelSpec{ |
| 1539 | RefreshSchedule: &runtimev1.Schedule{RefUpdate: true}, |
| 1540 | InputConnector: "duckdb", |
| 1541 | InputProperties: must(structpb.NewStruct(map[string]any{"sql": `SELECT 1`})), |
| 1542 | OutputConnector: "duckdb", |
| 1543 | ChangeMode: runtimev1.ModelChangeMode_MODEL_CHANGE_MODE_RESET, |
| 1544 | }, |
| 1545 | }, |
| 1546 | { |
| 1547 | Name: ResourceName{Kind: ResourceKindAlert, Name: "a1"}, |
nothing calls this directly
no test coverage detected