mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Single-binary web UI for visual skill management — React 19 + Vite frontend embedded via go:embed, Go net/http REST API backend (30+ endpoints). Includes dashboard, skills browser, targets, sync, collect, search, install, config editor, backup/restore, and git sync pages. Also adds Bitbucket/GitLab URL parsing for install, git operations library, skill version checking, CI frontend build steps, Docker sandbox support, and website docs for the ui command.
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package version
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestReadLocalSkillVersion(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
content string
|
|
expected string
|
|
}{
|
|
{
|
|
name: "reads version from SKILL.md",
|
|
content: `---
|
|
name: skillshare
|
|
version: 0.4.5
|
|
---
|
|
# Skillshare Skill`,
|
|
expected: "0.4.5",
|
|
},
|
|
{
|
|
name: "returns empty when no version field",
|
|
content: `---
|
|
name: skillshare
|
|
---
|
|
# Skillshare Skill`,
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "returns empty for empty file",
|
|
content: "",
|
|
expected: "",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
// Create source/skillshare/SKILL.md structure
|
|
sourceDir := t.TempDir()
|
|
skillDir := filepath.Join(sourceDir, "skillshare")
|
|
if err := os.MkdirAll(skillDir, 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte(tt.content), 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
got := ReadLocalSkillVersion(sourceDir)
|
|
if got != tt.expected {
|
|
t.Errorf("ReadLocalSkillVersion() = %q, want %q", got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestReadLocalSkillVersion_NoSkillDir(t *testing.T) {
|
|
sourceDir := t.TempDir()
|
|
got := ReadLocalSkillVersion(sourceDir)
|
|
if got != "" {
|
|
t.Errorf("expected empty string for missing skillshare dir, got %q", got)
|
|
}
|
|
}
|