From 0c5ea7b2a0d791db7f4bf835ef049292a6667562 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 15 Sep 2026 12:48:51 +1000 Subject: [PATCH] test(telegram): pin upload-ceiling agreement with send_file Choice: cross-package test (pin). Both ceiling pairs are live producers and currently agree, so the WIRE/DELETE rule does not apply. Deriving one shared definition would either require a new package outside this lane's ownership or bind the channel-free sendfile tool to the telegram package; the cross-package test pins the documented 'the two must agree' contract at the duplicate itself. --- internal/channels/telegram/media_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/channels/telegram/media_test.go b/internal/channels/telegram/media_test.go index b3c6b9bde..8edd297d2 100644 --- a/internal/channels/telegram/media_test.go +++ b/internal/channels/telegram/media_test.go @@ -16,6 +16,7 @@ import ( "github.com/go-telegram/bot" "github.com/samcharles93/archie-core/internal/gateway" + "github.com/samcharles93/archie-core/internal/tools/sendfile" ) // mediaAPI stands in for the Bot API, recording which sendX method was @@ -450,6 +451,22 @@ func TestSendMedia_LocalPathFailures(t *testing.T) { } } +// TestMediaUploadCeilingsAgreeWithSendFile pins the contract documented in +// sendfile/tool.go: the send_file early check and this sender's Bot API +// ceilings must be the same number, or an oversized file is reported "sent" +// by the tool and then silently rejected here -- the exact silent +// non-delivery send_file exists to end. +func TestMediaUploadCeilingsAgreeWithSendFile(t *testing.T) { + if sendfile.MaxImageUploadBytes != maxPhotoUploadBytes { + t.Errorf("send_file image ceiling = %d bytes, telegram photo ceiling = %d bytes; they must agree", + sendfile.MaxImageUploadBytes, maxPhotoUploadBytes) + } + if sendfile.MaxUploadBytes != maxFileUploadBytes { + t.Errorf("send_file upload ceiling = %d bytes, telegram file ceiling = %d bytes; they must agree", + sendfile.MaxUploadBytes, maxFileUploadBytes) + } +} + // A photo just under the photo ceiling must still be accepted -- the // per-type limits must not collapse into one conservative number. func TestSendMedia_PhotoUnderLimitIsSent(t *testing.T) {