skills: add SkillStore interface, Skill type, OriginKey, name validation

This commit is contained in:
sausheong committed 2026-05-09 15:42:33 +08:00
1 parent 4877db85ae
commit e9eea7c842
2 files changed
+185

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
package skills
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidName_Accepts(t *testing.T) {
for _, name := range []string{
"a",
"abc",
"my-skill",
"skill-with-many-dashes",
"a1b2c3",
"writing-clearly-and-concisely",
// 64 chars exactly
"abcdefghij-abcdefghij-abcdefghij-abcdefghij-abcdefghij-abcdefghi",
} {
assert.True(t, ValidName(name), "expected %q to validate", name)
}
}
func TestValidName_Rejects(t *testing.T) {
for _, name := range []string{
"", // empty
"-leading-dash", // can't start with dash
"UPPER", // no uppercase
"snake_case", // no underscores
"with space", // no spaces
"path/traversal", // no slashes
"..", // no dots
"my.skill", // no dots
"__reserved", // reserved prefix
// 65 chars (one over)
"abcdefghij-abcdefghij-abcdefghij-abcdefghij-abcdefghij-abcdefghij",
} {
assert.False(t, ValidName(name), "expected %q to be rejected", name)
}
}