¸ÄÓñ¾»ú¶ÀÁ¢ CA£¬»ָ´ CLI TLS УÑ飬±£»¤ƾ¾ÝÓëÅäÖò¢·¢±£´档 д Cursor Êý¾ݡ¢»Ự·¾¶¡¢´úÀíÉúÃüÖÜÆڡ¢ģÐÍÇëÇóÓë Skills Îļþ²Ù×÷¡£ Ϊ¶ÀÁ¢ Tab ·þÎñÔö¼ӿͻ§¶˼øȨ£¬Éý¼¶ÒÀÀµÓ빤¾ßÁ´£¬ÍêÉƷ¢²¼ԪÐÅϢͬ²½¡£ Ñé֤£ºÁ½¸ö Go ģ¿éµIJâÊÔ/vet¡¢¹ؼüģ¿é race¡¢ǰ¶˲âÊÔ/Éú²ú¹¹½¨/Éó¼ơ¢ Go ¿ɴï©¶´ɨÃèÓë macOS/Linux ¿ÉÐÐģ¿齻²æ±àÒë¾ùͨ¹ý¡£ Windows ¸ôÀëÆô¶¯ͨ¹ý£»δÍê³ɵĵã»÷ðÑ̺ÍԭÉúƽ̨Ñé֤¼ûÉó²鱨¸档
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package skills
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestUninstallRejectsUnknownSkillAndPreservesCustomFiles(t *testing.T) {
|
|
dir := t.TempDir()
|
|
custom := filepath.Join(dir, ".cursor", "skills", "user-owned")
|
|
_ = os.MkdirAll(custom, 0700)
|
|
file := filepath.Join(custom, "SKILL.md")
|
|
_ = os.WriteFile(file, []byte("user data"), 0600)
|
|
if err := Uninstall(dir, "user-owned"); err == nil {
|
|
t.Fatal("unknown skill accepted")
|
|
}
|
|
if _, err := os.Stat(file); err != nil {
|
|
t.Fatal("custom skill deleted")
|
|
}
|
|
if err := Install(dir, "fd-engineering"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
extra := filepath.Join(skillTargetDir(dir, "fd-engineering"), "my-notes.md")
|
|
_ = os.WriteFile(extra, []byte("notes"), 0600)
|
|
if err := Uninstall(dir, "fd-engineering"); err == nil {
|
|
t.Fatal("custom files silently deleted")
|
|
}
|
|
if _, err := os.Stat(extra); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestUninstallPreservesModifiedCommand(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if err := Install(dir, "fd-engineering"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
command := filepath.Join(projectCommandsDir(dir), "FD-plan.md")
|
|
if err := os.WriteFile(command, []byte("custom command"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := Uninstall(dir, "fd-engineering"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
data, err := os.ReadFile(command)
|
|
if err != nil || string(data) != "custom command" {
|
|
t.Fatal("modified command deleted")
|
|
}
|
|
}
|