Change summary
internal/config/load.go | 3 ++-
internal/env/env.go | 8 +++++++-
internal/env/env_test.go | 4 ++--
3 files changed, 11 insertions(+), 4 deletions(-)
Detailed changes
@@ -14,6 +14,7 @@ import (
"slices"
"strconv"
"strings"
+ "testing"
"github.com/charmbracelet/catwalk/pkg/catwalk"
"github.com/charmbracelet/crush/internal/csync"
@@ -672,7 +673,7 @@ func hasAWSCredentials(env env.Env) bool {
return true
}
- if _, err := os.Stat(filepath.Join(home.Dir(), ".aws/credentials")); err == nil {
+ if _, err := os.Stat(filepath.Join(home.Dir(), ".aws/credentials")); err == nil && !testing.Testing() {
return true
}
@@ -1,6 +1,9 @@
package env
-import "os"
+import (
+ "os"
+ "testing"
+)
type Env interface {
Get(key string) string
@@ -23,6 +26,9 @@ func (o *osEnv) Env() []string {
}
func New() Env {
+ if testing.Testing() {
+ return NewFromMap(nil)
+ }
return &osEnv{}
}
@@ -8,7 +8,7 @@ import (
)
func TestOsEnv_Get(t *testing.T) {
- env := New()
+ env := &osEnv{}
// Test getting an existing environment variable
t.Setenv("TEST_VAR", "test_value")
@@ -22,7 +22,7 @@ func TestOsEnv_Get(t *testing.T) {
}
func TestOsEnv_Env(t *testing.T) {
- env := New()
+ env := &osEnv{}
envVars := env.Env()