▍ humdrum codex / custard
license AGPL-3.0
1.5 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package backlog

import "testing"

func TestParse(t *testing.T) {
	raw := []byte(`---
id: TASK-007
title: Wire the issues view
status: In Progress
priority: high
labels:
  - feature
  - ui
dependencies:
  - TASK-001
ordinal: 7000
created_date: '2026-06-17 16:08'
updated_date: '2026-06-17 16:21'
---
Render backlog tasks as issues.

## Acceptance Criteria
- [ ] list view
- [x] detail view
`)
	got, err := ParseTask("task-007 - wire-the-issues-view", raw)
	if err != nil {
		t.Fatalf("ParseTask: %v", err)
	}
	if got.ID != "TASK-007" {
		t.Errorf("ID = %q, want TASK-007", got.ID)
	}
	if got.Key() != "task-007" {
		t.Errorf("Key = %q, want task-007", got.Key())
	}
	if got.Status != "In Progress" {
		t.Errorf("Status = %q", got.Status)
	}
	if got.Ordinal != 7000 {
		t.Errorf("Ordinal = %d, want 7000", got.Ordinal)
	}
	if len(got.Labels) != 2 || got.Labels[0] != "feature" {
		t.Errorf("Labels = %v", got.Labels)
	}
	if len(got.Deps) != 1 || got.Deps[0] != "TASK-001" {
		t.Errorf("Deps = %v", got.Deps)
	}
	if got.Body == "" || got.Body[0] == '-' {
		t.Errorf("Body not separated from frontmatter: %q", got.Body)
	}
}

func TestParseNoFrontmatter(t *testing.T) {
	got, err := ParseTask("loose-note", []byte("just a body, no frontmatter"))
	if err != nil {
		t.Fatalf("ParseTask: %v", err)
	}
	if got.ID != "loose-note" || got.Title != "loose-note" {
		t.Errorf("fallbacks not applied: id=%q title=%q", got.ID, got.Title)
	}
	if got.Status != "To Do" {
		t.Errorf("default status = %q, want To Do", got.Status)
	}
}