mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Add global project list, show, add, edit, sync and remove so setup scripts can register repositories without editing YAML or opening the dashboard. Keep dry runs read-only and report completed work when a target fails. Reuse the shared project service and sync runners. Include command docs, translations, completions and regression coverage. Quote overlap hints for their shell and log partial project syncs consistently with ordinary sync.
129 lines
3.4 KiB
Go
129 lines
3.4 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestHelp_ShowsUsage(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("help")
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "skillshare")
|
|
result.AssertOutputContains(t, "Skills and agents")
|
|
result.AssertOutputContains(t, "Common options")
|
|
}
|
|
|
|
func TestHelp_ShortFlag(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("-h")
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "Skills and agents")
|
|
}
|
|
|
|
func TestHelp_LongFlag(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("--help")
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "Skills and agents")
|
|
}
|
|
|
|
func TestNoArgs_ShowsUsage(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI()
|
|
result.AssertFailure(t)
|
|
result.AssertOutputContains(t, "Skills and agents")
|
|
}
|
|
|
|
func TestUnknownCommand_ShowsError(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("unknowncommand")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "Unknown command")
|
|
result.AssertOutputNotContains(t, "Skills and agents")
|
|
}
|
|
|
|
func TestUnknownCommand_SuggestsClosest(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("instal")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, `Did you mean "install"?`)
|
|
}
|
|
|
|
func TestLoneOption_ShowsUsage(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
result := sb.RunCLI("--no-tui")
|
|
result.AssertFailure(t)
|
|
result.AssertOutputNotContains(t, "Unknown command")
|
|
result.AssertOutputContains(t, "Skills and agents")
|
|
}
|
|
|
|
func TestHelp_PluginCommandsAndSyncBoundary(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
result := sb.RunCLI("plugin", "--help")
|
|
result.AssertSuccess(t)
|
|
for _, command := range []string{"list", "discover", "add", "import", "inspect", "sync", "check", "update", "enable", "disable", "remove", "skillshare sync plugins"} {
|
|
result.AssertOutputContains(t, command)
|
|
}
|
|
result = sb.RunCLI("sync", "--help")
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "Plugins are not included in --all")
|
|
result.AssertOutputContains(t, "skillshare sync plugins")
|
|
}
|
|
|
|
func TestSubcommandHelp_ShowsUsageInsteadOfRunning(t *testing.T) {
|
|
for _, args := range [][]string{
|
|
{"target", "add", "--help"},
|
|
{"project", "add", "--help"},
|
|
{"project", "remove", "--help"},
|
|
{"project", "list", "--help"},
|
|
{"project", "show", "--help"},
|
|
{"project", "edit", "--help"},
|
|
{"project", "sync", "--help"},
|
|
{"target", "remove", "--help"},
|
|
{"target", "list", "--help"},
|
|
{"trash", "list", "--help"},
|
|
{"trash", "empty", "--help"},
|
|
{"hub", "list", "--help"},
|
|
{"hub", "remove", "-h"},
|
|
} {
|
|
t.Run(args[0]+" "+args[1], func(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\n")
|
|
|
|
result := sb.RunCLI(args...)
|
|
result.AssertSuccess(t)
|
|
result.AssertOutputContains(t, "Usage skillshare "+args[0])
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestTUIToggleHelp_DoesNotChangeSetting(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\ntui: false\n")
|
|
|
|
sb.RunCLI("tui", "on", "--help").AssertSuccess(t)
|
|
|
|
sb.RunCLI("tui").AssertRowContains(t, "TUI", "off")
|
|
}
|