mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Many integration and handler tests re-checked rules that internal/ packages already test, duplicated each other, or ran no product code at all (a few re-implemented the logic inline, two could never fail). They slowed the suite without catching anything new. Delete those, keeping tests for CLI wiring, JSON output, exit codes, project/global mode and cmd-only logic. Move the agents/extras overlap check into sync.AgentTargetPaths so the CLI and the server share one implementation and it is covered by unit tests instead of seven integration tests.
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestMode_MutuallyExclusive(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("sync", "-p", "-g")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "mutually exclusive")
|
|
}
|
|
|
|
func TestMode_GlobalFlag_ForcesGlobal(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
// Create project dir with config
|
|
projectRoot := sb.SetupProjectDir("claude")
|
|
|
|
// Write global config
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets:
|
|
claude:
|
|
path: ` + filepath.Join(sb.Home, ".claude", "skills") + `
|
|
`)
|
|
|
|
// -g flag forces global even in project dir
|
|
result := sb.RunCLIInDir(projectRoot, "status", "-g")
|
|
result.AssertSuccess(t)
|
|
// Should show global source, not project source
|
|
result.AssertRowContains(t, "skills", "~/.config/skillshare/skills")
|
|
}
|
|
|
|
func TestMode_AutoDetect_GlobalWhenNoConfig(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
|
targets:
|
|
claude:
|
|
path: ` + filepath.Join(sb.Home, ".claude", "skills") + `
|
|
`)
|
|
sb.CreateSkill("global-skill", map[string]string{"SKILL.md": "# G"})
|
|
|
|
// Run from a dir without .skillshare/ → global mode
|
|
emptyDir := filepath.Join(sb.Root, "empty")
|
|
os.MkdirAll(emptyDir, 0755)
|
|
result := sb.RunCLIInDir(emptyDir, "list")
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "global-skill")
|
|
}
|
|
|
|
func TestMode_InstallTrackRequiresGitInProject(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
projectRoot := sb.SetupProjectDir("claude")
|
|
|
|
// --track now allowed in project mode, but requires a git source
|
|
result := sb.RunCLIInDir(projectRoot, "install", "/some/path", "--track", "-p")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "git repository source")
|
|
}
|