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

Function TestInMemoryTaskStore_Concurrency

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

Source from the content-addressed store, hash-verified

105}
106
107func TestInMemoryTaskStore_Concurrency(t *testing.T) {
108 store := NewInMemoryTaskStore()
109 agentID := "agent-1"
110
111 // 并发保存任务
112 const numTasks = 100
113 done := make(chan bool, numTasks)
114
115 for i := range numTasks {
116 go func(id int) {
117 task := NewTask(string(rune('a'+id)), "context-1")
118 _ = store.Save(agentID, task)
119 done <- true
120 }(i)
121 }
122
123 // 等待所有任务完成
124 for range numTasks {
125 <-done
126 }
127
128 // 验证任务已保存(数量可能少于numTasks,因为有ID冲突)
129 tasks, err := store.List(agentID)
130 require.NoError(t, err)
131 assert.NotEmpty(t, tasks)
132}
133
134func TestTask_StateTransitions(t *testing.T) {
135 task := NewTask("task-1", "context-1")

Callers

nothing calls this directly

Calls 4

SaveMethod · 0.95
ListMethod · 0.95
NewInMemoryTaskStoreFunction · 0.85
NewTaskFunction · 0.85

Tested by

no test coverage detected