parser/metadecoders: Consolidate the metadata decoders

See #5324
This commit is contained in:
Bjørn Erik Pedersen
2018-10-20 11:16:18 +02:00
parent 44da60d869
commit 129c27ee6e
22 changed files with 624 additions and 808 deletions

View File

@@ -18,6 +18,7 @@ import (
"testing"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/parser/metadecoders"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
@@ -179,12 +180,12 @@ func TestRemarshalDetectFormat(t *testing.T) {
data string
expect interface{}
}{
{`foo = "bar"`, "toml"},
{` foo = "bar"`, "toml"},
{`foo="bar"`, "toml"},
{`foo: "bar"`, "yaml"},
{`foo:"bar"`, "yaml"},
{`{ "foo": "bar"`, "json"},
{`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},
} {
@@ -198,6 +199,6 @@ func TestRemarshalDetectFormat(t *testing.T) {
}
assert.NoError(err, errMsg)
assert.Equal(test.expect, result, errMsg)
assert.Equal(test.expect, result)
}
}