Skip to content

Commit

Permalink
add test case for issue docker#5057
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahKimel committed May 17, 2024
1 parent ad3bcf8 commit 1bb7836
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions opts/envfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ func TestParseEnvFileNonExistentFile(t *testing.T) {
}
}

// Test TestParseEnvFile for a badly formatted header
func TestParseEnvFileFormattedWithSpace(t *testing.T) {
content := `
[config 1]
foo=bar
f=quux
`
tmpFile := tmpFileWithContent(t, content)

_, err := ParseEnvFile(tmpFile)
if err == nil {
t.Fatalf("Expected an ErrBadKey, got nothing")
}
if _, ok := err.(ErrBadKey); !ok {
t.Fatalf("Expected an ErrBadKey, got [%v]", err)
}
expectedMessage := "poorly formatted environment: variable '[config 1]' contains whitespaces"
if err.Error() != expectedMessage {
t.Fatalf("Expected [%v], got [%v]", expectedMessage, err.Error())
}
}

// Test ParseEnvFile for a badly formatted file
func TestParseEnvFileBadlyFormattedFile(t *testing.T) {
content := `foo=bar
Expand Down

0 comments on commit 1bb7836

Please sign in to comment.