Fix scanner tests on Windows
This is necessary because of the effects of autocrlf on Windows.
This commit is contained in:
parent
fdad785730
commit
4b7727828a
@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/hcl/hcl/ast"
|
||||
"github.com/hashicorp/hcl/testhelper"
|
||||
)
|
||||
|
||||
func TestDecode_interface(t *testing.T) {
|
||||
@ -88,12 +89,12 @@ func TestDecode_interface(t *testing.T) {
|
||||
{
|
||||
"multiline.hcl",
|
||||
false,
|
||||
map[string]interface{}{"foo": "bar\nbaz\n"},
|
||||
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n")},
|
||||
},
|
||||
{
|
||||
"multiline_no_eof.hcl",
|
||||
false,
|
||||
map[string]interface{}{"foo": "bar\nbaz\n", "key": "value"},
|
||||
map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n"), "key": "value"},
|
||||
},
|
||||
{
|
||||
"multiline.json",
|
||||
|
15
testhelper/unix2dos.go
Normal file
15
testhelper/unix2dos.go
Normal file
@ -0,0 +1,15 @@
|
||||
package testhelper
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Converts the line endings when on Windows
|
||||
func Unix2dos(unix string) string {
|
||||
if runtime.GOOS != "windows" {
|
||||
return unix
|
||||
}
|
||||
|
||||
return strings.Replace(unix, "\n", "\r\n", -1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user