Merge pull request #4130 from hashicorp/b-windows-heredoc
Add regression test for #4069
This commit is contained in:
commit
20beafd31e
|
@ -45,6 +45,36 @@ func TestLoadFile_badType(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLoadFileWindowsLineEndings(t *testing.T) {
|
||||
testFile := filepath.Join(fixtureDir, "windows-line-endings.tf")
|
||||
|
||||
contents, err := ioutil.ReadFile(testFile)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if !strings.Contains(string(contents), "\r\n") {
|
||||
t.Fatalf("Windows line endings test file %s contains no windows line endings - this may be an autocrlf related issue.", testFile)
|
||||
}
|
||||
|
||||
c, err := LoadFile(testFile)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if c == nil {
|
||||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != "" {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := resourcesStr(c.Resources)
|
||||
if actual != strings.TrimSpace(windowsHeredocResourcesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFileHeredoc(t *testing.T) {
|
||||
c, err := LoadFile(filepath.Join(fixtureDir, "heredoc.tf"))
|
||||
if err != nil {
|
||||
|
@ -673,6 +703,11 @@ cloudstack_firewall[test] (x1)
|
|||
rule
|
||||
`
|
||||
|
||||
const windowsHeredocResourcesStr = `
|
||||
aws_instance[test] (x1)
|
||||
user_data
|
||||
`
|
||||
|
||||
const heredocProvidersStr = `
|
||||
aws
|
||||
access_key
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
windows-line-endings.tf eol=crlf
|
|
@ -0,0 +1,6 @@
|
|||
// This is a comment
|
||||
resource "aws_instance" "test" {
|
||||
user_data = <<HEREDOC
|
||||
test script
|
||||
HEREDOC
|
||||
}
|
Loading…
Reference in New Issue