Files
BBQ f376a2abe3 fix(channel): add wechatoa webhook delivery and proxy config (#356)
Unify webhook handling across channel adapters and add the WeChat Official Account channel so inbound routing and replies work without platform-specific handlers. Add adapter-scoped proxy support and stable config field ordering so restricted network environments can deliver WeChat and Telegram messages reliably.
2026-04-10 21:26:11 +08:00

40 lines
939 B
Go

package wechatoa
import (
"context"
"testing"
"github.com/memohai/memoh/internal/channel"
)
func TestBuildSendPayload_ImagePlatformKey(t *testing.T) {
client := &apiClient{}
payload, err := client.buildSendPayload(context.Background(), channel.PreparedMessage{
Message: channel.Message{
Attachments: []channel.Attachment{
{Type: channel.AttachmentImage, PlatformKey: "mid_123"},
},
},
})
if err != nil {
t.Fatalf("buildSendPayload error = %v", err)
}
if payload["msgtype"] != "image" {
t.Fatalf("unexpected msgtype: %v", payload["msgtype"])
}
}
func TestBuildSendPayload_UnsupportedAttachment(t *testing.T) {
client := &apiClient{}
_, err := client.buildSendPayload(context.Background(), channel.PreparedMessage{
Message: channel.Message{
Attachments: []channel.Attachment{
{Type: channel.AttachmentFile, PlatformKey: "mid_file"},
},
},
})
if err == nil {
t.Fatal("expected error")
}
}