Skip to content

test: add unit tests for core task operations #17

@LudoLoops

Description

@LudoLoops

Issue

No unit tests exist for critical functions like:

  • CreateTask
  • ReadTaskFile / WriteTaskFile
  • GetTasks
  • MarkTaskDone
  • Task YAML parsing/serialization

Problem

  • Hard to verify changes don't break existing functionality
  • Impossible to test edge cases (invalid YAML, missing files, etc.)
  • Refactoring is risky
  • No regression detection

Solution

Create task_test.go with tests for:

func TestReadTaskFile(t *testing.T) {
    // Test valid task file
    // Test missing file
    // Test invalid YAML
    // Test malformed frontmatter
}

func TestCreateTask(t *testing.T) {
    // Test basic creation
    // Test duplicate prevention
    // Test with GitHub issue
    // Test special characters in title
}

func TestGetTasks(t *testing.T) {
    // Test empty vault
    // Test multiple projects
    // Test filtering by project
}

Tools

Use Go's built-in testing package + t.TempDir() for isolated tests.

Benefits

  • Catch regressions before shipping
  • Enable safe refactoring
  • Document expected behavior
  • Improve code reliability

Impact

🟢 Low - But highly recommended

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions