Skip to content

Commit

Permalink
Merge pull request #4130 from hashicorp/b-windows-heredoc
Browse files Browse the repository at this point in the history
Add regression test for #4069
  • Loading branch information
jen20 committed Dec 1, 2015
2 parents 4efb443 + 5ea2536 commit 20beafd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
35 changes: 35 additions & 0 deletions config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -673,6 +703,11 @@ cloudstack_firewall[test] (x1)
rule
`

const windowsHeredocResourcesStr = `
aws_instance[test] (x1)
user_data
`

const heredocProvidersStr = `
aws
access_key
Expand Down
1 change: 1 addition & 0 deletions config/test-fixtures/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
windows-line-endings.tf eol=crlf
6 changes: 6 additions & 0 deletions config/test-fixtures/windows-line-endings.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This is a comment
resource "aws_instance" "test" {
user_data = <<HEREDOC
test script
HEREDOC
}

0 comments on commit 20beafd

Please sign in to comment.