Unit tests for helper functions
(t *testing.T)
| 501 | // Unit tests for helper functions |
| 502 | |
| 503 | func TestExtractCompletedSubtasks(t *testing.T) { |
| 504 | tests := []struct { |
| 505 | name string |
| 506 | body string |
| 507 | want []string |
| 508 | }{ |
| 509 | { |
| 510 | name: "mixed checked and unchecked", |
| 511 | body: "- [x] Done one\n- [ ] Not done\n- [x] Done two\n", |
| 512 | want: []string{"Done one", "Done two"}, |
| 513 | }, |
| 514 | { |
| 515 | name: "uppercase X", |
| 516 | body: "- [X] Done with uppercase\n", |
| 517 | want: []string{"Done with uppercase"}, |
| 518 | }, |
| 519 | { |
| 520 | name: "no subtasks", |
| 521 | body: "Just some text\n", |
| 522 | want: nil, |
| 523 | }, |
| 524 | { |
| 525 | name: "empty body", |
| 526 | body: "", |
| 527 | want: nil, |
| 528 | }, |
| 529 | { |
| 530 | name: "indented checkboxes", |
| 531 | body: " - [x] Indented item\n", |
| 532 | want: []string{"Indented item"}, |
| 533 | }, |
| 534 | } |
| 535 | |
| 536 | for _, tt := range tests { |
| 537 | t.Run(tt.name, func(t *testing.T) { |
| 538 | got := extractCompletedSubtasks(tt.body) |
| 539 | if len(got) != len(tt.want) { |
| 540 | t.Fatalf("extractCompletedSubtasks() = %v, want %v", got, tt.want) |
| 541 | } |
| 542 | for i := range got { |
| 543 | if got[i] != tt.want[i] { |
| 544 | t.Errorf("extractCompletedSubtasks()[%d] = %q, want %q", i, got[i], tt.want[i]) |
| 545 | } |
| 546 | } |
| 547 | }) |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | func TestParseDiffResult(t *testing.T) { |
| 552 | tests := []struct { |
nothing calls this directly
no test coverage detected