mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
@@ -18,7 +18,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/parser/metadecoders"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -171,34 +170,3 @@ func TestTestRemarshalError(t *testing.T) {
|
||||
assert.Error(err)
|
||||
|
||||
}
|
||||
|
||||
func TestRemarshalDetectFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert := require.New(t)
|
||||
|
||||
for i, test := range []struct {
|
||||
data string
|
||||
expect interface{}
|
||||
}{
|
||||
{`foo = "bar"`, metadecoders.TOML},
|
||||
{` foo = "bar"`, metadecoders.TOML},
|
||||
{`foo="bar"`, metadecoders.TOML},
|
||||
{`foo: "bar"`, metadecoders.YAML},
|
||||
{`foo:"bar"`, metadecoders.YAML},
|
||||
{`{ "foo": "bar"`, metadecoders.JSON},
|
||||
{`asdfasdf`, false},
|
||||
{``, false},
|
||||
} {
|
||||
errMsg := fmt.Sprintf("[%d] %s", i, test.data)
|
||||
|
||||
result, err := detectFormat(test.data)
|
||||
|
||||
if b, ok := test.expect.(bool); ok && !b {
|
||||
assert.Error(err, errMsg)
|
||||
continue
|
||||
}
|
||||
|
||||
assert.NoError(err, errMsg)
|
||||
assert.Equal(test.expect, result)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user