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>
33 lines
737 B
Go
33 lines
737 B
Go
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)
|
|
}
|
|
}
|