Skip to content

Improve test coverage and fix map enumeration bug in DAG task filters#5

Merged
badubizzle merged 3 commits intomasterfrom
copilot/update-test-coverage
Mar 4, 2026
Merged

Improve test coverage and fix map enumeration bug in DAG task filters#5
badubizzle merged 3 commits intomasterfrom
copilot/update-test-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

Test coverage was minimal, leaving core DAG, task, run, and store logic largely untested. Three functions also had a silent runtime bug due to incorrect map enumeration.

Bug Fix

get_completed_tasks/1, get_pending_tasks/1, and get_running_tasks/1 iterated over dag.tasks (a map) but passed the resulting {key, value} tuples directly to DAGTask.is_completed/1 etc., which pattern-match on %DAGTask{} — causing FunctionClauseError on any non-empty call.

# Before — crashes at runtime when tasks exist
Enum.filter(dag.tasks, fn task -> DAGTask.is_completed(task) end)

# After — correctly destructures map entries
Enum.filter(dag.tasks, fn {_task_id, task} -> DAGTask.is_completed(task) end)

New Test Files

  • test/dag_task_test.exsDAGTask.new/1, validate/1, is_pending/1, is_completed/1, is_running/1, status helpers, set_handler/2
  • test/dag_run_test.exsDAGRun.new/1, generate_id/0, random_string/1, uniqueness guarantees, timestamp fields
  • test/dag_task_run_test.exsDAGTaskRun.new/3, field initialization, payload storage, timestamps

Expanded Coverage in ex_dag_test.exs

Additional ExDag.DAG cases covering: get_tasks/1, set_handler/2, set_default_task_handler/2, set_tasks_handler/2, validate_for_run/1 (disconnected graph), get_deps/2, get_deps_map/1, get_runs/2, status accessors, completed?/1, get_completed_tasks/1, get_pending_tasks/1, get_running_tasks/1, sorted_tasks/1, should_run_task/2, clear_failed_tasks_runs/1, String.Chars impl, keyword-based add_task, and add_task!/2 throw behavior.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…Run modules

Co-authored-by: badubizzle <1519511+badubizzle@users.noreply.github.com>
Copilot AI changed the title [WIP] Update test coverage for existing features Improve test coverage and fix map enumeration bug in DAG task filters Mar 4, 2026
@badubizzle badubizzle marked this pull request as ready for review March 4, 2026 04:59
@badubizzle badubizzle merged commit 9842b53 into master Mar 4, 2026
1 check passed
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.

2 participants