on main help sign in
test: fix local test suite, ignore machine environ (#1605)
commitf32733cd86dc79c381de6d4fb1ae12d815bd669f authorAndrey Nering <andreynering@users.noreply.github.com> dateThu 11 Dec 2025, 14:21 (1 year ago) parentef61c05
3 files changed+11−4
internal/config/load.go+2−1 internal/env/env.go+7−1 internal/env/env_test.go+2−2
internal/config/load.go+2−1
@@ -14,6 +14,7 @@ import (
1414 "slices"
1515 "strconv"
1616 "strings"
17+ "testing"
1718
1819 "github.com/charmbracelet/catwalk/pkg/catwalk"
1920 "github.com/charmbracelet/crush/internal/csync"
@@ -672,7 +673,7 @@ func hasAWSCredentials(env env.Env) bool {
672673 return true
673674 }
674675
675− if _, err := os.Stat(filepath.Join(home.Dir(), ".aws/credentials")); err == nil {
676+ if _, err := os.Stat(filepath.Join(home.Dir(), ".aws/credentials")); err == nil && !testing.Testing() {
676677 return true
677678 }
678679
internal/env/env.go+7−1
@@ -1,6 +1,9 @@
11package env
22
3−import "os"
3+import (
4+ "os"
5+ "testing"
6+)
47
58type Env interface {
69 Get(key string) string
@@ -23,6 +26,9 @@ func (o *osEnv) Env() []string {
2326}
2427
2528func New() Env {
29+ if testing.Testing() {
30+ return NewFromMap(nil)
31+ }
2632 return &osEnv{}
2733}
2834
internal/env/env_test.go+2−2
@@ -8,7 +8,7 @@ import (
88)
99
1010func TestOsEnv_Get(t *testing.T) {
11− env := New()
11+ env := &osEnv{}
1212
1313 // Test getting an existing environment variable
1414 t.Setenv("TEST_VAR", "test_value")
@@ -22,7 +22,7 @@ func TestOsEnv_Get(t *testing.T) {
2222}
2323
2424func TestOsEnv_Env(t *testing.T) {
25− env := New()
25+ env := &osEnv{}
2626
2727 envVars := env.Env()
2828