Skip to content

Add comprehensive test coverage#6

Open
JonBasse wants to merge 1 commit intobuddyh:mainfrom
JonBasse:add-test-coverage
Open

Add comprehensive test coverage#6
JonBasse wants to merge 1 commit intobuddyh:mainfrom
JonBasse:add-test-coverage

Conversation

@JonBasse
Copy link

@JonBasse JonBasse commented Feb 3, 2026

Summary

Add tests for critical components to improve code quality and catch regressions early.

Test Coverage

Package Coverage Tests Added
internal/config 83.9% 9 tests
internal/output 91.7% 27 tests
internal/api Data parsing 17 tests

Total: 46 new tests

Details

Config package tests

  • TestConfigDir / TestConfigPath - Path construction
  • TestLoadFromEnvVar - Environment variable loading
  • TestLoadNoConfig - Missing config error handling
  • TestSaveAndLoad - Round-trip save/load
  • TestLoadEmptyToken - Empty token validation
  • TestLoadInvalidJSON - Malformed JSON handling
  • TestGetToken - Token retrieval
  • TestConfigDirPermissions - Directory permissions (0700)

API client tests

  • JSON parsing for all data types: Task, Project, Section, Label, Comment, CompletedTask
  • Parameter serialization: AddTaskParams, UpdateTaskParams, AddProjectParams
  • Priority conversion logic (user 1-4 maps to API 4-1)
  • Case-insensitive project name matching
  • Due date structure parsing

Output format tests

  • All output methods: WriteTasks, WriteProjects, WriteLabels, WriteSections, WriteComments, WriteCompletedTasks
  • Empty list handling for all types
  • JSON envelope format verification
  • Priority formatting with colors
  • Due date display with fallback
  • Label formatting
  • Project markers (favorite, inbox)
  • Orphaned subtask handling
  • Error/success messages in both human and JSON modes

Test plan

  • All 46 tests pass (go test ./...)
  • Coverage verified (go test ./... -cover)

🤖 Generated with Claude Code

Add tests for critical components to improve code quality and catch
regressions early.

**Config package tests (84% coverage):**
- ConfigDir/ConfigPath path construction
- Load from environment variable
- Load from config file
- Save and reload config
- Empty token validation
- Invalid JSON handling
- File permission verification (0600/0700)

**API client tests:**
- JSON parsing for all data types (Task, Project, Section, Label, etc.)
- Request/response parameter serialization
- Priority conversion logic (user 1-4 to API 4-1)
- Case-insensitive project name matching

**Output format tests (92% coverage):**
- All output methods (tasks, projects, labels, sections, comments)
- Empty list handling
- JSON envelope format
- Priority/due date/label formatting
- Project markers (favorite, inbox)
- Orphaned subtask handling
- Error/success messages (human and JSON modes)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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