File size: 988 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package smoke

import (
	"testing"

	"github.com/target/goalert/test/smoke/harness"
)

// TestCMTestDisable checks for a condition where a test message is scheduled but the contact method is immediately disabled.
func TestCMTestDisable(t *testing.T) {
	t.Parallel()

	sqlQuery := `
		insert into users (id, name, email) 
		values 
			({{uuid "user"}}, 'bob', 'joe');
		insert into user_contact_methods (id, user_id, name, type, value, disabled) 
		values
			({{uuid "cm1"}}, {{uuid "user"}}, 'personal', 'SMS', {{phone "1"}}, true),
			({{uuid "cm2"}}, {{uuid "user"}}, 'personal2', 'SMS', {{phone "2"}}, false);
		insert into outgoing_messages (message_type, contact_method_id, last_status, user_id)
		values
			('test_notification', {{uuid "cm1"}}, 'pending', {{uuid "user"}}),
			('test_notification', {{uuid "cm2"}}, 'pending', {{uuid "user"}});
	`
	h := harness.NewHarness(t, sqlQuery, "add-verification-code")
	defer h.Close()

	h.Twilio(t).Device(h.Phone("2")).ExpectSMS("test")
}