@@ -167,9 +167,9 @@ func TestTodoTool_UpdateTodos(t *testing.T) {
167167func TestTodoTool_UpdateTodos_PartialFailure (t * testing.T ) {
168168 tool := NewTodoTool ()
169169
170- // Create a single todo
171- _ , err := tool .handler .createTodo (t .Context (), CreateTodoArgs {
172- Description : "Test todo item" ,
170+ // Create two todos so we can complete one without clearing the list
171+ _ , err := tool .handler .createTodos (t .Context (), CreateTodosArgs {
172+ Descriptions : [] string { "First todo item", "Second todo item" } ,
173173 })
174174 require .NoError (t , err )
175175
@@ -185,10 +185,11 @@ func TestTodoTool_UpdateTodos_PartialFailure(t *testing.T) {
185185 assert .Contains (t , result .Output , "Updated 1 todos" )
186186 assert .Contains (t , result .Output , "Not found: nonexistent" )
187187
188- // Verify the existing todo was updated
188+ // Verify the existing todo was updated (list not cleared because todo_2 still pending)
189189 todos := tool .handler .todos .All ()
190- require .Len (t , todos , 1 )
190+ require .Len (t , todos , 2 )
191191 assert .Equal (t , "completed" , todos [0 ].Status )
192+ assert .Equal (t , "pending" , todos [1 ].Status )
192193}
193194
194195func TestTodoTool_UpdateTodos_AllNotFound (t * testing.T ) {
@@ -206,6 +207,35 @@ func TestTodoTool_UpdateTodos_AllNotFound(t *testing.T) {
206207 assert .Contains (t , result .Output , "Not found: nonexistent1, nonexistent2" )
207208}
208209
210+ func TestTodoTool_UpdateTodos_ClearsWhenAllCompleted (t * testing.T ) {
211+ tool := NewTodoTool ()
212+
213+ // Create multiple todos
214+ _ , err := tool .handler .createTodos (t .Context (), CreateTodosArgs {
215+ Descriptions : []string {"First todo item" , "Second todo item" },
216+ })
217+ require .NoError (t , err )
218+
219+ // Complete all todos
220+ result , err := tool .handler .updateTodos (t .Context (), UpdateTodosArgs {
221+ Updates : []TodoUpdate {
222+ {ID : "todo_1" , Status : "completed" },
223+ {ID : "todo_2" , Status : "completed" },
224+ },
225+ })
226+ require .NoError (t , err )
227+ assert .Contains (t , result .Output , "Updated 2 todos" )
228+
229+ // Verify all todos were cleared
230+ todos := tool .handler .todos .All ()
231+ assert .Empty (t , todos )
232+
233+ // Verify Meta is also empty
234+ metaTodos , ok := result .Meta .([]Todo )
235+ require .True (t , ok , "Meta should be []Todo" )
236+ assert .Empty (t , metaTodos )
237+ }
238+
209239func TestTodoTool_OutputSchema (t * testing.T ) {
210240 tool := NewTodoTool ()
211241
0 commit comments