picoclaw/pkg/channels/whatsapp/whatsapp_command_test.go

22 lines
526 B
Go

package whatsapp
import (
"context"
"testing"
"github.com/sipeed/picoclaw/pkg/commands"
)
func TestTryHandleCommand_UsesDispatcher(t *testing.T) {
ch := &WhatsAppChannel{}
called := false
ch.dispatcher = commands.DispatchFunc(func(context.Context, commands.Request) commands.Result {
called = true
return commands.Result{Matched: true}
})
handled := ch.tryHandleCommand(context.Background(), "/help", "chat1", "user1", "mid1")
if !handled || !called {
t.Fatalf("handled=%v called=%v", handled, called)
}
}