Fix tests (bd-6ss and sub-issues) (#626)

Test coverage improvements for bd-6ss. Fixing failing test assumption in follow-up commit.
This commit is contained in:
matt wilkie
2025-12-18 19:23:30 -07:00
committed by GitHub
parent 7f9ee3d1c4
commit fb16e504e6
14 changed files with 1656 additions and 10 deletions

View File

@@ -1,7 +1,10 @@
package validation
import (
"strings"
"testing"
"github.com/steveyegge/beads/internal/types"
)
func TestParsePriority(t *testing.T) {
@@ -106,6 +109,62 @@ func TestValidateIDFormat(t *testing.T) {
}
}
func TestParseIssueType(t *testing.T) {
tests := []struct {
name string
input string
wantType types.IssueType
wantError bool
errorContains string
}{
// Valid issue types
{"bug type", "bug", types.TypeBug, false, ""},
{"feature type", "feature", types.TypeFeature, false, ""},
{"task type", "task", types.TypeTask, false, ""},
{"epic type", "epic", types.TypeEpic, false, ""},
{"chore type", "chore", types.TypeChore, false, ""},
// Case sensitivity (function is case-sensitive)
{"uppercase bug", "BUG", types.TypeTask, true, "invalid issue type"},
{"mixed case feature", "FeAtUrE", types.TypeTask, true, "invalid issue type"},
// With whitespace
{"bug with spaces", " bug ", types.TypeBug, false, ""},
{"feature with tabs", "\tfeature\t", types.TypeFeature, false, ""},
// Invalid issue types
{"invalid type", "invalid", types.TypeTask, true, "invalid issue type"},
{"empty string", "", types.TypeTask, true, "invalid issue type"},
{"whitespace only", " ", types.TypeTask, true, "invalid issue type"},
{"numeric type", "123", types.TypeTask, true, "invalid issue type"},
{"special chars", "bug!", types.TypeTask, true, "invalid issue type"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ParseIssueType(tt.input)
// Check error conditions
if (err != nil) != tt.wantError {
t.Errorf("ParseIssueType(%q) error = %v, wantError %v", tt.input, err, tt.wantError)
return
}
if err != nil && tt.errorContains != "" {
if !strings.Contains(err.Error(), tt.errorContains) {
t.Errorf("ParseIssueType(%q) error message = %q, should contain %q", tt.input, err.Error(), tt.errorContains)
}
return
}
// Check return value
if got != tt.wantType {
t.Errorf("ParseIssueType(%q) = %v, want %v", tt.input, got, tt.wantType)
}
})
}
}
func TestValidatePrefix(t *testing.T) {
tests := []struct {
name string