Assign readable ticket keys from project code and sequence.
Replace UUID-looking sync labels in TUI and web with keys like TAS-1, while keeping the remote UUID for task-master matching. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package sqlite
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDeriveProjectCode(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, want string
|
||||
}{
|
||||
{"Alpha", "ALP"},
|
||||
{"task-master", "TAS"},
|
||||
{"AB", "ABX"},
|
||||
{"12", "XXX"},
|
||||
{"Büro Projekt", "BRO"}, // non-ASCII letters skipped
|
||||
{"my project", "MYP"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := DeriveProjectCode(tc.name); got != tc.want {
|
||||
t.Errorf("DeriveProjectCode(%q)=%q want %q", tc.name, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextUniqueCode(t *testing.T) {
|
||||
used := map[string]bool{"ALP": true, "ALA": true}
|
||||
got := nextUniqueCode("Alpha", used)
|
||||
if got == "ALP" || got == "ALA" {
|
||||
t.Fatalf("expected unique code, got %q", got)
|
||||
}
|
||||
if len(got) != 3 {
|
||||
t.Fatalf("len=%d code=%q", len(got), got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user