Files
2dph/internal/cmdbin/exec_test.go
T
eSliderandGitHub 20b78a9a20
Tests / Test (push) Failing after 5s
Tests / Release (semver) (push) Skipped
feat: brain/index.go shebang; mail import is not a brain write (D14). (#12)
Commands live at bin/brain/{index,get,stats,eval,watch}.go and
bin/mail/import.go, bin/markdown/import.go, bin/postgres/query.go.
Python remains the Ladybug write worker. index_mail is a deprecation
shim that rebuilds via --with-mail.
2026-08-13 17:46:25 +01:00

35 lines
739 B
Go

package cmdbin
import (
"os"
"path/filepath"
"testing"
)
func TestRootHonorsKBROOT(t *testing.T) {
dir := t.TempDir()
t.Setenv("KB_ROOT", dir)
if got := Root(); got != dir {
t.Fatalf("Root() = %q, want %q", got, dir)
}
}
func TestExecFileMissingIs127(t *testing.T) {
t.Setenv("KB_ROOT", t.TempDir())
if code := ExecFile("no/such-tool", nil); code != 127 {
t.Fatalf("exit = %d, want 127", code)
}
}
func TestExecFileRuns(t *testing.T) {
root := t.TempDir()
script := filepath.Join(root, "echo.sh")
if err := os.WriteFile(script, []byte("#!/bin/sh\nexit 3\n"), 0o755); err != nil {
t.Fatal(err)
}
t.Setenv("KB_ROOT", root)
if code := ExecFile("echo.sh", nil); code != 3 {
t.Fatalf("exit = %d, want 3", code)
}
}