MCPcopy Create free account
hub / github.com/astercloud/aster / TestTask_AddMessage

Function TestTask_AddMessage

pkg/a2a/store_test.go:150–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestTask_AddMessage(t *testing.T) {
151 task := NewTask("task-1", "context-1")
152
153 // 添加用户消息
154 userMsg := Message{
155 MessageID: "msg-1",
156 Role: "user",
157 Parts: []Part{{Kind: "text", Text: "Hello"}},
158 }
159 task.AddMessage(userMsg)
160
161 // 添加代理消息
162 agentMsg := Message{
163 MessageID: "msg-2",
164 Role: "agent",
165 Parts: []Part{{Kind: "text", Text: "Hi there"}},
166 }
167 task.AddMessage(agentMsg)
168
169 // 验证历史记录
170 assert.Len(t, task.History, 2)
171 assert.Equal(t, "msg-1", task.History[0].MessageID)
172 assert.Equal(t, "user", task.History[0].Role)
173 assert.Equal(t, "msg-2", task.History[1].MessageID)
174 assert.Equal(t, "agent", task.History[1].Role)
175}

Callers

nothing calls this directly

Calls 3

AddMessageMethod · 0.95
NewTaskFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected