Skip to content

test(todo): add unit tests for has_duplicates, generate_new_todo_id, and deserialization#3739

Open
sandikodev wants to merge 5 commits intoaws:mainfrom
sandikodev:test/delegate-todo-coverage
Open

test(todo): add unit tests for has_duplicates, generate_new_todo_id, and deserialization#3739
sandikodev wants to merge 5 commits intoaws:mainfrom
sandikodev:test/delegate-todo-coverage

Conversation

@sandikodev
Copy link
Copy Markdown

@sandikodev sandikodev commented Apr 9, 2026

Motivation

Several tool files had zero tests despite containing non-trivial logic. This PR adds unit test coverage for functions that can be tested without an Os instance.

Changes

todo.rs (was 0 tests):

  • has_duplicates: empty, unique, and duplicate cases
  • generate_new_todo_id: uniqueness and numeric-only format
  • TodoList deserialization: Create, Complete, Add, Remove variants

tools/mod.rs (was 2 tests, adds 3 more):

  • Absolute path passes through unchanged
  • Empty string does not panic
  • Tilde only expands at the start of a path

custom_tool.rs (was 0 tests):

  • default_timeout is 120,000ms (2 minutes)
  • get_default_scopes returns non-empty strings
  • TransportType::default() is Stdio

knowledge.rs (was 0 tests):

  • Knowledge deserialization: Add, Search, Remove, Clear variants

Testing

cargo test -p chat_cli

348 passed, 0 failed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…and deserialization

todo.rs had zero tests. Add coverage for:
- has_duplicates: empty, unique, and duplicate cases
- generate_new_todo_id: uniqueness (with sleep) and numeric format
- TodoList deserialization: Create, Complete, Add, Remove variants
Add three additional tests covering:
- absolute path passes through unchanged
- empty string does not panic
- tilde only expands at the start of a path, not in the middle
…tion

custom_tool.rs:
- default_timeout is 120_000ms (2 minutes)
- get_default_scopes returns non-empty strings
- TransportType::default() is Stdio

knowledge.rs:
- TodoList deserialization for Add, Search, Remove, Clear variants
thinking.rs (was 0 tests):
- deserialization
- invoke returns empty output
- validate accepts both empty and non-empty thoughts

introspect.rs (was 0 tests):
- deserialization with and without query
- validate always succeeds
…zation

delegate.rs had only 1 test (get_schema). Add coverage for:
- truncate_description: period truncation, long string, short string
- format_launch_success: contains agent name and task
- AgentStatus::default is Running
- Delegate deserialization: Launch with task, Status without agent
- resolve_agent_name fallback chain (explicit > configured > default)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant