diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-26 22:07:07 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-26 22:07:07 +0200 |
| commit | b10c6247e14a3acfe20e78426e131691e205a601 (patch) | |
| tree | 907bb5b3ffa8239584ae9b7c2bfc34667b095b62 /internal/askcli/completion_test.go | |
| parent | bef3cc7dd95745a5724d3569e45fe7be4aba02ee (diff) | |
ask: add fish completions for task CLI
Diffstat (limited to 'internal/askcli/completion_test.go')
| -rw-r--r-- | internal/askcli/completion_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/askcli/completion_test.go b/internal/askcli/completion_test.go new file mode 100644 index 0000000..e717575 --- /dev/null +++ b/internal/askcli/completion_test.go @@ -0,0 +1,46 @@ +package askcli + +import ( + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestFishCompletion_MatchesAsset(t *testing.T) { + _, file, _, ok := runtime.Caller(0) + if !ok { + t.Fatal("runtime.Caller failed") + } + assetPath := filepath.Clean(filepath.Join(filepath.Dir(file), "..", "..", "assets", "ask.fish")) + want, err := os.ReadFile(assetPath) + if err != nil { + t.Fatalf("read asset: %v", err) + } + got := FishCompletion() + if got != string(want) { + t.Fatalf("fish completion asset mismatch\n--- got ---\n%s\n--- want ---\n%s", got, string(want)) + } +} + +func TestFishCompletion_IncludesCommandsAndExcludesExport(t *testing.T) { + script := FishCompletion() + for _, name := range []string{"add", "list", "all", "ready", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete", "help"} { + if !strings.Contains(script, " -a '"+name+"' ") { + t.Fatalf("script missing root completion for %q", name) + } + } + for _, line := range []string{ + "complete -c ask -n '__ask_in_dep_context' -a 'add' -d 'Add a dependency'", + "complete -c ask -n '__ask_in_dep_context' -a 'rm' -d 'Remove a dependency'", + "complete -c ask -n '__ask_in_dep_context' -a 'list' -d 'List dependencies'", + } { + if !strings.Contains(script, line) { + t.Fatalf("script missing dep completion line %q", line) + } + } + if strings.Contains(script, "ask export") { + t.Fatalf("script should not advertise non-existent export command") + } +} |
