MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestNewChatMessageSendPlan

Function TestNewChatMessageSendPlan

internal/cmd/chat_message_send_plan_test.go:12–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestNewChatMessageSendPlan(t *testing.T) {
13 home, err := os.UserHomeDir()
14 if err != nil {
15 t.Fatalf("UserHomeDir: %v", err)
16 }
17
18 plan, err := newChatMessageSendPlan(chatMessageSendInput{
19 Space: "AAA",
20 Text: " hello ",
21 Thread: " t1 ",
22 Attachments: []string{"~/pic.png"},
23 })
24 if err != nil {
25 t.Fatalf("newChatMessageSendPlan: %v", err)
26 }
27 if plan.Space != "spaces/AAA" || plan.Text != "hello" {
28 t.Fatalf("unexpected message plan: %#v", plan)
29 }
30 if plan.ThreadRaw != "t1" || plan.ThreadName != "spaces/AAA/threads/t1" {
31 t.Fatalf("unexpected thread plan: %#v", plan)
32 }
33 if len(plan.Attachments) != 1 || plan.Attachments[0] != filepath.Join(home, "pic.png") {
34 t.Fatalf("unexpected attachments: %#v", plan.Attachments)
35 }
36 if plan.replyOption() != chatReplyFallbackToNewThread {
37 t.Fatalf("replyOption() = %q", plan.replyOption())
38 }
39
40 attachment := &chat.Attachment{}
41 message := plan.message([]*chat.Attachment{attachment})
42 if message.Text != "hello" || message.Thread == nil || message.Thread.Name != plan.ThreadName {
43 t.Fatalf("unexpected message: %#v", message)
44 }
45 if len(message.Attachment) != 1 || message.Attachment[0] != attachment {
46 t.Fatalf("unexpected message attachments: %#v", message.Attachment)
47 }
48
49 payload := plan.dryRunPayload()
50 if payload["reply_fallback_to_new_thread"] != true || payload["thread"] != plan.ThreadName {
51 t.Fatalf("unexpected dry-run payload: %#v", payload)
52 }
53}
54
55func TestNewChatMessageSendPlanAttachmentOnly(t *testing.T) {
56 plan, err := newChatMessageSendPlan(chatMessageSendInput{

Callers

nothing calls this directly

Calls 4

newChatMessageSendPlanFunction · 0.85
replyOptionMethod · 0.80
messageMethod · 0.80
dryRunPayloadMethod · 0.45

Tested by

no test coverage detected