mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
The shared AGENTS.md workflow is dashboard-only, so users had no written reference for how shared files attach, what restore puts back, or where drift backups go. Adds a how-to page in every locale, documents single-file extras and the target `instructions` key, and brings the translated extras collect section up to date with English.
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateExtraName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
wantErr bool
|
|
}{
|
|
// valid names
|
|
{name: "rules", wantErr: false},
|
|
{name: "my-commands", wantErr: false},
|
|
{name: "team_prompts", wantErr: false},
|
|
{name: "a1", wantErr: false},
|
|
// reserved names
|
|
{name: "skills", wantErr: true},
|
|
{name: "extras", wantErr: true},
|
|
// empty
|
|
{name: "", wantErr: true},
|
|
// path traversal / invalid characters
|
|
{name: "../escape", wantErr: true},
|
|
{name: "has space", wantErr: true},
|
|
{name: "has/slash", wantErr: true},
|
|
{name: "-starts-dash", wantErr: true},
|
|
{name: "_starts-under", wantErr: true},
|
|
{name: ".hidden", wantErr: true},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
err := ValidateExtraName(tc.name)
|
|
if tc.wantErr && err == nil {
|
|
t.Errorf("ValidateExtraName(%q) = nil, want error", tc.name)
|
|
}
|
|
if !tc.wantErr && err != nil {
|
|
t.Errorf("ValidateExtraName(%q) = %v, want nil", tc.name, err)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestValidateExtraName_NoDuplicate(t *testing.T) {
|
|
existing := []ExtraConfig{{Name: "rules"}}
|
|
|
|
if err := ValidateExtraNameUnique("rules", existing); err == nil {
|
|
t.Error("ValidateExtraNameUnique(\"rules\", existing) = nil, want error for duplicate")
|
|
}
|
|
|
|
if err := ValidateExtraNameUnique("commands", existing); err != nil {
|
|
t.Errorf("ValidateExtraNameUnique(\"commands\", existing) = %v, want nil", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateExtraName_CaseOnlyDifferenceIsDuplicate(t *testing.T) {
|
|
if err := ValidateExtraNameUnique("Rules", []ExtraConfig{{Name: "rules"}}); err == nil {
|
|
t.Error("ValidateExtraNameUnique(\"Rules\", [rules]) = nil, want error")
|
|
}
|
|
}
|