|
package smoke |
|
|
|
import ( |
|
"testing" |
|
"time" |
|
|
|
"github.com/target/goalert/test/smoke/harness" |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestAddRules(t *testing.T) { |
|
t.Parallel() |
|
|
|
sql := ` |
|
insert into users (id, name, email) |
|
values |
|
({{uuid "uid"}}, 'bob', 'joe'); |
|
|
|
insert into user_contact_methods (id, user_id, name, type, value) |
|
values |
|
({{uuid "cid"}}, {{uuid "uid"}}, 'personal', 'SMS', {{phone "1"}}); |
|
|
|
insert into user_notification_rules (user_id, contact_method_id, delay_minutes) |
|
values |
|
({{uuid "uid"}}, {{uuid "cid"}}, 0), |
|
({{uuid "uid"}}, {{uuid "cid"}}, 60); |
|
|
|
insert into escalation_policies (id, name, repeat) |
|
values |
|
({{uuid "eid"}}, 'esc policy', -1); |
|
insert into escalation_policy_steps (id, escalation_policy_id, delay) |
|
values |
|
({{uuid "esid"}}, {{uuid "eid"}}, 300); |
|
|
|
insert into escalation_policy_actions (escalation_policy_step_id, user_id) |
|
values |
|
({{uuid "esid"}}, {{uuid "uid"}}); |
|
|
|
insert into services (id, escalation_policy_id, name) |
|
values |
|
({{uuid "sid"}}, {{uuid "eid"}}, 'service'); |
|
|
|
insert into alerts (service_id, description) |
|
values |
|
({{uuid "sid"}}, 'testing'); |
|
|
|
` |
|
h := harness.NewHarness(t, sql, "ids-to-uuids") |
|
defer h.Close() |
|
|
|
tw := h.Twilio(t) |
|
d := tw.Device(h.Phone("1")) |
|
d.ExpectSMS("testing") |
|
|
|
h.FastForward(35 * time.Minute) |
|
h.Trigger() |
|
|
|
|
|
h.AddNotificationRule(h.UUID("uid"), h.UUID("cid"), 30) |
|
h.AddNotificationRule(h.UUID("uid"), h.UUID("cid"), 90) |
|
|
|
h.FastForward(30 * time.Minute) |
|
|
|
d.ExpectSMS("testing") |
|
|
|
h.FastForward(30 * time.Minute) |
|
|
|
d.ExpectSMS("testing") |
|
|
|
h.Escalate(1, 0) |
|
|
|
d.ExpectSMS("testing") |
|
|
|
h.FastForward(30 * time.Minute) |
|
|
|
d.ExpectSMS("testing") |
|
} |
|
|