A .env file in the working directory is now optional

This commit is contained in:
bwilliams committed 2026-10-21 15:28:52 +01:00
1 parent 0b1952bd69
commit 1e3acaeff3
5 files changed
+30 -9

No files matched your search

+7 -1
View File
@@ -73,11 +73,17 @@ func TestConfigFlag(t *testing.T) {
}
}
func TestMissingEnvFile(t *testing.T) {
// A .env file is optional, but one that can't be parsed is an error.
func TestEnvFile(t *testing.T) {
cmdtest.Setup(t, appConfig)
if err := os.Remove(".env"); err != nil {
t.Fatal(err)
}
if _, err := cmdtest.Run(t, newRoot, "", "level"); err != nil {
t.Errorf("without a .env file: %v; want no error", err)
}
cmdtest.WriteFile(t, ".env", "NOT VALID\n")
_, err := cmdtest.Run(t, newRoot, "", "level")
cmdtest.ErrContains(t, err, ".env")
}