From 238ad537fc409b3332b9c419351c70e14410bad5 Mon Sep 17 00:00:00 2001 From: thesyncim Date: Tue, 24 Nov 2026 10:46:44 +0000 Subject: [PATCH] test(channels): a failed claim answers without the store's text --- acceleration/internal/api/channels_test.go | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/acceleration/internal/api/channels_test.go b/acceleration/internal/api/channels_test.go index d18975daa8..444b5288e3 100644 --- a/acceleration/internal/api/channels_test.go +++ b/acceleration/internal/api/channels_test.go @@ -526,6 +526,43 @@ func (s *ChannelsSuite) TestAStartTheStoreRefusedIsObeyedWhenDeliveredAgain() { s.Len(s.meta.to(writer), 3, "the START is confirmed once, however often it is delivered") } +// A HELP or an ordinary message the store could not claim fails its delivery with a 500 the +// provider retries, saying nothing of the store, whose error goes to the log. A trigger +// refuses the line's deliveries. +func (s *ChannelsSuite) TestAMessageTheStoreCouldNotClaimIsA500WithoutTheStoresWords() { + number := s.number() + line := s.connect(number) + s.agentOn(number, "") + ctx := context.Background() + _, err := s.store.GlobalDB().ExecContext(ctx, `BEGIN; + CREATE FUNCTION channels_suite_refuse_delivery() RETURNS trigger AS $$ + BEGIN RAISE EXCEPTION 'refused by the test'; END $$ LANGUAGE plpgsql; + CREATE TRIGGER channels_suite_refuse_delivery BEFORE INSERT ON channel_deliveries FOR EACH ROW + WHEN (NEW.account_id = '`+line.Id+`') EXECUTE FUNCTION channels_suite_refuse_delivery(); + COMMIT`) + s.Require().NoError(err) + defer func() { + _, err := s.store.GlobalDB().ExecContext(ctx, `BEGIN; + DROP TRIGGER channels_suite_refuse_delivery ON channel_deliveries; + DROP FUNCTION channels_suite_refuse_delivery(); + COMMIT`) + s.Require().NoError(err) + }() + + for _, text := range []string{"HELP", "what time do you open?"} { + writer := s.writer() + body := s.delivery(writer, "msg-"+s.utils.uuid(), text) + status, answered := s.post(line.WebhookUrl, s.signed(body), body) + s.Equal(http.StatusInternalServerError, status, "%q not claimed is the provider's to deliver again", text) + s.Contains(string(answered), "something went wrong", text) + s.NotContains(string(answered), "refused by the test", text) + s.NotContains(string(answered), "claim channel message", text) + s.Empty(s.meta.to(writer), "%q not claimed is not answered", text) + } + s.Contains(s.logged.String(), `level=ERROR msg="could not claim a channel delivery" customer=`+s.customerID()) + s.Contains(s.logged.String(), "refused by the test", "what the store said is kept in the log") +} + // A delivery of a STOP racing a slow first one waits for the first to record the opt-out, and // both are answered as taken: the person is opted out and confirmed once. func (s *ChannelsSuite) TestARedeliveryRacingASlowStopWaitsForIt() {