A .env file in the working directory is now optional
This commit is contained in:
1 parent
0b1952bd69
commit
1e3acaeff3
5 files changed
+30
-9
No files matched your search
@@ -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")
|
||||
}
|
||||
Reference in new issue
Block a user