Files
gastown/internal/config/test_main_test.go
Erik LaBianca 43e38f037c fix: stabilize beads and config tests (#560)
* fix: stabilize beads and config tests

* fix: remove t.Parallel() incompatible with t.Setenv()

The test now uses t.Setenv() which cannot be used with t.Parallel() in Go.
This completes the conflict resolution from the rebase.

* style: fix gofmt issue in beads_test.go

Remove extra blank line in comment block.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 15:29:18 -08:00

43 lines
799 B
Go

package config
import (
"fmt"
"os"
"path/filepath"
"testing"
)
func TestMain(m *testing.M) {
stubDir, err := os.MkdirTemp("", "gt-agent-bin-*")
if err != nil {
fmt.Fprintf(os.Stderr, "create stub dir: %v\n", err)
os.Exit(1)
}
stub := []byte("#!/bin/sh\nexit 0\n")
binaries := []string{
"claude",
"gemini",
"codex",
"cursor-agent",
"auggie",
"amp",
}
for _, name := range binaries {
path := filepath.Join(stubDir, name)
if err := os.WriteFile(path, stub, 0755); err != nil {
fmt.Fprintf(os.Stderr, "write stub %s: %v\n", name, err)
os.Exit(1)
}
}
originalPath := os.Getenv("PATH")
_ = os.Setenv("PATH", stubDir+string(os.PathListSeparator)+originalPath)
code := m.Run()
_ = os.Setenv("PATH", originalPath)
_ = os.RemoveAll(stubDir)
os.Exit(code)
}