Don't convert windows newlines

If the canonical newline is a single LF, don't insert CRLF in tests
This commit is contained in:
James Bardin 2016-12-01 10:22:15 -05:00
parent a97a4ff95f
commit aaca009935

View File

@ -9,7 +9,6 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/hcl/hcl/ast"
"github.com/hashicorp/hcl/testhelper"
)
func TestDecode_interface(t *testing.T) {
@ -89,8 +88,7 @@ func TestDecode_interface(t *testing.T) {
{
"multiline_literal_with_hil.hcl",
false,
map[string]interface{}{"multiline_literal_with_hil": testhelper.Unix2dos(`${hello
world}`)},
map[string]interface{}{"multiline_literal_with_hil": "${hello\n world}"},
},
{
"multiline_no_marker.hcl",
@ -100,22 +98,22 @@ func TestDecode_interface(t *testing.T) {
{
"multiline.hcl",
false,
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n")},
map[string]interface{}{"foo": "bar\nbaz\n"},
},
{
"multiline_indented.hcl",
false,
map[string]interface{}{"foo": testhelper.Unix2dos(" bar\n baz\n")},
map[string]interface{}{"foo": " bar\n baz\n"},
},
{
"multiline_no_hanging_indent.hcl",
false,
map[string]interface{}{"foo": testhelper.Unix2dos(" baz\n bar\n foo\n")},
map[string]interface{}{"foo": " baz\n bar\n foo\n"},
},
{
"multiline_no_eof.hcl",
false,
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n"), "key": "value"},
map[string]interface{}{"foo": "bar\nbaz\n", "key": "value"},
},
{
"multiline.json",
@ -394,31 +392,32 @@ func TestDecode_interface(t *testing.T) {
}
for _, tc := range cases {
t.Logf("Testing: %s", tc.File)
d, err := ioutil.ReadFile(filepath.Join(fixtureDir, tc.File))
if err != nil {
t.Fatalf("err: %s", err)
}
t.Run(tc.File, func(t *testing.T) {
d, err := ioutil.ReadFile(filepath.Join(fixtureDir, tc.File))
if err != nil {
t.Fatalf("err: %s", err)
}
var out interface{}
err = Decode(&out, string(d))
if (err != nil) != tc.Err {
t.Fatalf("Input: %s\n\nError: %s", tc.File, err)
}
var out interface{}
err = Decode(&out, string(d))
if (err != nil) != tc.Err {
t.Fatalf("Input: %s\n\nError: %s", tc.File, err)
}
if !reflect.DeepEqual(out, tc.Out) {
t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out)
}
if !reflect.DeepEqual(out, tc.Out) {
t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out)
}
var v interface{}
err = Unmarshal(d, &v)
if (err != nil) != tc.Err {
t.Fatalf("Input: %s\n\nError: %s", tc.File, err)
}
var v interface{}
err = Unmarshal(d, &v)
if (err != nil) != tc.Err {
t.Fatalf("Input: %s\n\nError: %s", tc.File, err)
}
if !reflect.DeepEqual(v, tc.Out) {
t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out)
}
if !reflect.DeepEqual(v, tc.Out) {
t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out)
}
})
}
}