mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
The Git and CLI groups listed command names on one line with no summaries, so finding the command for a task meant opening each one's help. Give them a row and summary like every other group.
130 lines
3.5 KiB
Go
130 lines
3.5 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")
|
|
result.AssertOutputContains(t, "Pull the source and sync every Target")
|
|
}
|
|
|
|
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")
|
|
}
|