Files
skillshare/internal/version/skill_test.go
T
Willie 092fb14f8a feat: add web dashboard with embedded React SPA (skillshare ui)
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.
2026-02-08 05:08:30 +08:00

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)
}
}