talk is going to be published. Code comments, CLI output, error messages,
daemon log lines, MCP descriptions and results, test names and assertions,
README, spec, skill, build scripts and flake are now English. Only the
spoken announcement texts stay bilingual: the wrap result and the test
sentence are German or English depending on the detected language.
Language fallback is now configurable: `lang = "en" | "de"` (env
TALK_LANG, default en) is used when detection cannot tell (numbers, single
words, ties) and for talk's own announcements. langdetect.Detect takes the
fallback as an argument instead of hard-coding German. `talk setup` asks for
it; `talk doctor` and `talk status` show it.
Vocabulary pinned across packages so the process-boundary tests observe
stable strings: chain log lines ("chain: tier X skipped (not available)",
"falling back to the next tier", "spoken via X"), queue lines ("discarded:
quiet hours ... active", "replaced by toast", "max_age"), CLI notes
("speaking directly", "daemon started at", "no daemon", "nothing to cancel"),
status block with aligned English labels, MCP messages, origin guard 403.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package notify
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestShowCallsNotifySend: on Linux, Show goes through notify-send; here a
|
|
// fake in PATH that records its arguments (a real process, no mock
|
|
// framework). Title and text arrive unchanged.
|
|
func TestShowCallsNotifySend(t *testing.T) {
|
|
if runtime.GOOS != "linux" {
|
|
t.Skip("the notify-send path exists only on Linux")
|
|
}
|
|
dir := t.TempDir()
|
|
seen := filepath.Join(dir, "seen.txt")
|
|
script := "#!/bin/sh\nprintf '%s\\n' \"$@\" > \"" + seen + "\"\n"
|
|
if err := os.WriteFile(filepath.Join(dir, "notify-send"), []byte(script), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Setenv("PATH", dir)
|
|
|
|
if !Available() {
|
|
t.Fatal("Available = false with fake in PATH")
|
|
}
|
|
if err := Show(context.Background(), "quiet hours: build done"); err != nil {
|
|
t.Fatalf("Show: %v", err)
|
|
}
|
|
b, err := os.ReadFile(seen)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
args := strings.Split(strings.TrimSpace(string(b)), "\n")
|
|
if args[len(args)-1] != "quiet hours: build done" || args[len(args)-2] != Title {
|
|
t.Errorf("notify-send arguments = %q, want ... %q %q", args, Title, "quiet hours: build done")
|
|
}
|
|
}
|
|
|
|
// TestShowWithoutTool: a missing tool is a clear error.
|
|
func TestShowWithoutTool(t *testing.T) {
|
|
t.Setenv("PATH", t.TempDir())
|
|
if Available() {
|
|
t.Fatal("Available = true without tool")
|
|
}
|
|
if err := Show(context.Background(), "x"); err == nil {
|
|
t.Error("Show without tool: no error")
|
|
}
|
|
if !strings.Contains(Describe(), "not found") {
|
|
t.Errorf("Describe = %q", Describe())
|
|
}
|
|
}
|
|
|
|
func TestAppleString(t *testing.T) {
|
|
if got := appleString(`say "hello" \ bye`); got != `"say \"hello\" \\ bye"` {
|
|
t.Errorf("appleString = %s", got)
|
|
}
|
|
}
|