-
Notifications
You must be signed in to change notification settings - Fork 531
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerstestingTest implementationTest implementation
Description
Summary
The task import functions in lib/task_sources.sh lack integration tests for the actual import logic. Current tests only verify detection (whether tools are available) but skip testing the parsing and import functionality.
Current Test Gap Analysis
| Function | Current Tests | Gap |
|---|---|---|
fetch_beads_tasks() |
0 | No tests - JSON parsing, text fallback, status filtering untested |
fetch_github_tasks() |
0 | No tests - JSON parsing, label filtering untested |
get_beads_count() |
1 | Only tests unavailable case, not actual counting |
get_github_issue_count() |
1 | Only tests unavailable case, not actual counting |
import_tasks_from_sources() |
1 | Only tests PRD source, not beads/github sources |
Context
PR #150 fixed several bugs in fetch_beads_tasks():
- Fixed
bd listarguments (non-existent--filterflag) - Fixed jq
!=bash escaping issue - Added status-respecting fallback for text parsing
- Added jq guards for missing id/title fields
These fixes were only manually tested. Integration tests would prevent regressions.
Proposed Tests
1. Beads Import Tests (fetch_beads_tasks)
# Test JSON parsing with mocked bd command
@test "fetch_beads_tasks parses JSON output correctly" {
# Mock bd to return JSON
bd() { echo '[{"id":"proj-001","title":"Fix bug","status":"open"}]'; }
export -f bd
...
}
# Test text fallback parsing
@test "fetch_beads_tasks falls back to text parsing when JSON fails" {
# Mock bd to return text format
bd() { echo "○ proj-001 [● P2] [task] - Fix authentication bug"; }
...
}
# Test status filtering
@test "fetch_beads_tasks respects filterStatus parameter" { ... }
# Test empty results
@test "fetch_beads_tasks handles empty JSON array" { ... }
# Test malformed JSON fallback
@test "fetch_beads_tasks falls back to text on malformed JSON" { ... }
# Test missing fields (jq guards)
@test "fetch_beads_tasks filters entries with missing id" { ... }
@test "fetch_beads_tasks filters entries with missing title" { ... }2. GitHub Import Tests (fetch_github_tasks)
# Test JSON parsing
@test "fetch_github_tasks parses issue JSON correctly" {
# Mock gh to return JSON
gh() { echo '[{"number":123,"title":"Add feature"}]'; }
...
}
# Test label filtering
@test "fetch_github_tasks filters by label" { ... }
# Test limit parameter
@test "fetch_github_tasks respects limit parameter" { ... }
# Test empty results
@test "fetch_github_tasks handles no matching issues" { ... }3. Combined Import Tests (import_tasks_from_sources)
# Test beads source
@test "import_tasks_from_sources imports from beads" { ... }
# Test github source
@test "import_tasks_from_sources imports from github" { ... }
# Test multiple sources
@test "import_tasks_from_sources combines beads and github" { ... }4. Count Function Tests
@test "get_beads_count returns correct count from JSON" { ... }
@test "get_github_issue_count returns correct count" { ... }Implementation Approach
-
Create mock command helpers in
tests/helpers/:mock_bd()- Returns configurable JSON/text outputmock_gh()- Returns configurable issue JSON
-
Add fixture data in
tests/helpers/fixtures.bash:- Sample beads JSON responses
- Sample beads text output
- Sample GitHub issue JSON
-
Create test file:
tests/integration/test_task_imports.bats
Acceptance Criteria
-
fetch_beads_tasks()has tests for JSON parsing, text fallback, status filtering, and edge cases -
fetch_github_tasks()has tests for JSON parsing, label filtering, and edge cases -
import_tasks_from_sources()tested with beads and github sources - Count functions tested with actual data
- All tests use mocked commands (no external dependencies)
- Tests cover the PR fix: beads task import uses correct bd list arguments #150 fixes to prevent regression
Labels
testingenhancementgood first issue
Related
- PR fix: beads task import uses correct bd list arguments #150 - fix: beads task import uses correct bd list arguments
lib/task_sources.sh- Source file under testtests/unit/test_task_sources.bats- Existing unit tests
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerstestingTest implementationTest implementation