mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
667fc85d54
add new field type to Channel struct config.channels refactor to channel_list update config version to 3 update the docs
38 lines
885 B
Go
38 lines
885 B
Go
package whatsapp
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/bus"
|
|
"github.com/sipeed/picoclaw/pkg/channels"
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
func TestHandleIncomingMessage_DoesNotConsumeGenericCommandsLocally(t *testing.T) {
|
|
messageBus := bus.NewMessageBus()
|
|
ch := &WhatsAppChannel{
|
|
BaseChannel: channels.NewBaseChannel("whatsapp", config.WhatsAppSettings{}, messageBus, nil),
|
|
ctx: context.Background(),
|
|
}
|
|
|
|
ch.handleIncomingMessage(map[string]any{
|
|
"type": "message",
|
|
"id": "mid1",
|
|
"from": "user1",
|
|
"chat": "chat1",
|
|
"content": "/help",
|
|
})
|
|
|
|
inbound, ok := <-messageBus.InboundChan()
|
|
if !ok {
|
|
t.Fatal("expected inbound message to be forwarded")
|
|
}
|
|
if inbound.Channel != "whatsapp" {
|
|
t.Fatalf("channel=%q", inbound.Channel)
|
|
}
|
|
if inbound.Content != "/help" {
|
|
t.Fatalf("content=%q", inbound.Content)
|
|
}
|
|
}
|