MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / TestFindFallsBackToHome

Function TestFindFallsBackToHome

internal/envfile/envfile_test.go:67–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestFindFallsBackToHome(t *testing.T) {
68 home := t.TempDir()
69 t.Setenv("HOME", home)
70 t.Setenv("CAM_CONFIG_DIR", filepath.Join(home, "cfg"))
71 if err := os.WriteFile(filepath.Join(home, ".env"), []byte("FOO=bar\n"), 0o600); err != nil {
72 t.Fatal(err)
73 }
74
75 // Walk-upward must not find a sibling .env: chdir to an isolated tempdir
76 // with a .git marker so the walk stops immediately.
77 other := t.TempDir()
78 if err := os.MkdirAll(filepath.Join(other, ".git"), 0o755); err != nil {
79 t.Fatal(err)
80 }
81 wd, _ := os.Getwd()
82 if err := os.Chdir(other); err != nil {
83 t.Fatal(err)
84 }
85 t.Cleanup(func() { _ = os.Chdir(wd) })
86
87 got, err := envfile.Find("", false)
88 if err != nil {
89 t.Fatalf("Find err = %v", err)
90 }
91 if got != filepath.Join(home, ".env") {
92 t.Fatalf("Find = %q, want %q", got, filepath.Join(home, ".env"))
93 }
94}
95
96func TestLoadParsesKeyValuePairs(t *testing.T) {
97 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

FindFunction · 0.92

Tested by

no test coverage detected