@@ -431,29 +431,6 @@ func TestGetMessagesByID(t *testing.T) {
431
431
assert .Equal (t , "in 1" , msgs [0 ].Text ())
432
432
}
433
433
434
- func TestGetChannelMessagesForInterrupt (t * testing.T ) {
435
- ctx , _ , db , _ := testsuite .Get ()
436
-
437
- defer testsuite .Reset (testsuite .ResetData )
438
-
439
- testdata .InsertIncomingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "in 1" , models .MsgStatusHandled )
440
- testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "out 1" , []utils.Attachment {"image/jpeg:hi.jpg" }, models .MsgStatusSent , false )
441
- testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "out 2" , nil , models .MsgStatusSent , false )
442
- testdata .InsertOutgoingMsg (db , testdata .Org2 , testdata .Org2Channel , testdata .Org2Contact , "out 3" , nil , models .MsgStatusSent , false )
443
- testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "out 3" , nil , models .MsgStatusErrored , false )
444
- testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "out 4" , nil , models .MsgStatusPending , false )
445
- testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "out 5" , nil , models .MsgStatusQueued , false )
446
-
447
- msgs , err := models .GetChannelMessagesToInterrupt (ctx , db , testdata .Org1 .ID , testdata .TwilioChannel .ID )
448
-
449
- // should only return the outgoing messages for this org
450
- require .NoError (t , err )
451
- assert .Equal (t , 3 , len (msgs ))
452
- assert .Equal (t , "out 3" , msgs [0 ].Text ())
453
- assert .Equal (t , "out 4" , msgs [1 ].Text ())
454
- assert .Equal (t , "out 5" , msgs [2 ].Text ())
455
- }
456
-
457
434
func TestResendMessages (t * testing.T ) {
458
435
ctx , rt , db , rp := testsuite .Get ()
459
436
@@ -512,35 +489,29 @@ func TestResendMessages(t *testing.T) {
512
489
}
513
490
514
491
func TestFailMessages (t * testing.T ) {
515
- ctx , rt , db , rp := testsuite .Get ()
492
+ ctx , _ , db , _ := testsuite .Get ()
516
493
517
494
defer testsuite .Reset (testsuite .ResetAll )
518
495
519
- oa , err := models .GetOrgAssets (ctx , rt , testdata .Org1 .ID )
520
- require .NoError (t , err )
521
-
522
496
out1 := testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "hi" , nil , models .MsgStatusPending , false )
523
497
out2 := testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Bob , "hi" , nil , models .MsgStatusErrored , false )
524
498
out3 := testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "hi" , nil , models .MsgStatusFailed , false )
525
499
out4 := testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .Cathy , "hi" , nil , models .MsgStatusQueued , false )
526
- out5 := testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .George , "hi" , nil , models .MsgStatusQueued , false )
500
+ testdata .InsertOutgoingMsg (db , testdata .Org1 , testdata .TwilioChannel , testdata .George , "hi" , nil , models .MsgStatusQueued , false )
527
501
528
502
ids := []models.MsgID {models .MsgID (out1 .ID ()), models .MsgID (out2 .ID ()), models .MsgID (out3 .ID ()), models .MsgID (out4 .ID ())}
529
-
530
- msgs , err := models .GetMessagesByID (ctx , db , testdata .Org1 .ID , models .DirectionOut , ids )
531
- require .NoError (t , err )
503
+ println (ids )
532
504
533
505
now := dates .Now ()
534
506
535
507
// fail the msgs
536
- failedMsgs , err := models .FailMessages (ctx , db , rp , oa , msgs )
508
+ err := models .FailChannelMessages (ctx , db , testdata . Org1 . ID , testdata . TwilioChannel . ID )
537
509
require .NoError (t , err )
538
510
539
- assert .Len (t , failedMsgs , 3 )
511
+ // assert.Len(t, failedMsgs, 3)
540
512
541
- assertdb .Query (t , db , `SELECT count(*) FROM msgs_msg WHERE status = 'F' AND modified_on > $1` , now ).Returns (3 )
513
+ assertdb .Query (t , db , `SELECT count(*) FROM msgs_msg WHERE status = 'F' AND modified_on > $1` , now ).Returns (4 )
542
514
assertdb .Query (t , db , `SELECT status FROM msgs_msg WHERE id = $1` , out3 .ID ()).Columns (map [string ]interface {}{"status" : "F" })
543
- assertdb .Query (t , db , `SELECT status FROM msgs_msg WHERE id = $1` , out5 .ID ()).Columns (map [string ]interface {}{"status" : "Q" })
544
515
545
516
}
546
517
0 commit comments