diff options
Diffstat (limited to 'parser')
-rw-r--r-- | parser/metadecoders/decoder_test.go | 33 | ||||
-rw-r--r-- | parser/metadecoders/format_test.go | 27 | ||||
-rw-r--r-- | parser/pageparser/pagelexer_test.go | 12 |
3 files changed, 35 insertions, 37 deletions
diff --git a/parser/metadecoders/decoder_test.go b/parser/metadecoders/decoder_test.go index 7cb66d736..3cb2e6365 100644 --- a/parser/metadecoders/decoder_test.go +++ b/parser/metadecoders/decoder_test.go @@ -14,15 +14,14 @@ package metadecoders import ( - "fmt" "reflect" "testing" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) func TestUnmarshalToMap(t *testing.T) { - assert := require.New(t) + c := qt.New(t) expect := map[string]interface{}{"a": "b"} @@ -44,19 +43,19 @@ func TestUnmarshalToMap(t *testing.T) { {`a = b`, TOML, false}, {`a,b,c`, CSV, false}, // Use Unmarshal for CSV } { - msg := fmt.Sprintf("%d: %s", i, test.format) + msg := qt.Commentf("%d: %s", i, test.format) m, err := d.UnmarshalToMap([]byte(test.data), test.format) if b, ok := test.expect.(bool); ok && !b { - assert.Error(err, msg) + c.Assert(err, qt.Not(qt.IsNil), msg) } else { - assert.NoError(err, msg) - assert.Equal(test.expect, m, msg) + c.Assert(err, qt.IsNil, msg) + c.Assert(m, qt.DeepEquals, test.expect, msg) } } } func TestUnmarshalToInterface(t *testing.T) { - assert := require.New(t) + c := qt.New(t) expect := map[string]interface{}{"a": "b"} @@ -77,13 +76,13 @@ func TestUnmarshalToInterface(t *testing.T) { // errors {`a = "`, TOML, false}, } { - msg := fmt.Sprintf("%d: %s", i, test.format) + msg := qt.Commentf("%d: %s", i, test.format) m, err := d.Unmarshal([]byte(test.data), test.format) if b, ok := test.expect.(bool); ok && !b { - assert.Error(err, msg) + c.Assert(err, qt.Not(qt.IsNil), msg) } else { - assert.NoError(err, msg) - assert.Equal(test.expect, m, msg) + c.Assert(err, qt.IsNil, msg) + c.Assert(m, qt.DeepEquals, test.expect, msg) } } @@ -91,7 +90,7 @@ func TestUnmarshalToInterface(t *testing.T) { } func TestUnmarshalStringTo(t *testing.T) { - assert := require.New(t) + c := qt.New(t) d := Default @@ -110,13 +109,13 @@ func TestUnmarshalStringTo(t *testing.T) { {"[3,7,9]", []interface{}{}, []interface{}{3, 7, 9}}, {"[3.1,7.2,9.3]", []interface{}{}, []interface{}{3.1, 7.2, 9.3}}, } { - msg := fmt.Sprintf("%d: %T", i, test.to) + msg := qt.Commentf("%d: %T", i, test.to) m, err := d.UnmarshalStringTo(test.data, test.to) if b, ok := test.expect.(bool); ok && !b { - assert.Error(err, msg) + c.Assert(err, qt.Not(qt.IsNil), msg) } else { - assert.NoError(err, msg) - assert.Equal(test.expect, m, msg) + c.Assert(err, qt.IsNil, msg) + c.Assert(m, qt.DeepEquals, test.expect, msg) } } diff --git a/parser/metadecoders/format_test.go b/parser/metadecoders/format_test.go index 7794843b1..74d105010 100644 --- a/parser/metadecoders/format_test.go +++ b/parser/metadecoders/format_test.go @@ -14,19 +14,18 @@ package metadecoders import ( - "fmt" "testing" "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/parser/pageparser" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) func TestFormatFromString(t *testing.T) { - assert := require.New(t) - for i, test := range []struct { + c := qt.New(t) + for _, test := range []struct { s string expect Format }{ @@ -39,13 +38,13 @@ func TestFormatFromString(t *testing.T) { {"org", ORG}, {"foo", ""}, } { - assert.Equal(test.expect, FormatFromString(test.s), fmt.Sprintf("t%d", i)) + c.Assert(FormatFromString(test.s), qt.Equals, test.expect) } } func TestFormatFromMediaType(t *testing.T) { - assert := require.New(t) - for i, test := range []struct { + c := qt.New(t) + for _, test := range []struct { m media.Type expect Format }{ @@ -54,13 +53,13 @@ func TestFormatFromMediaType(t *testing.T) { {media.TOMLType, TOML}, {media.CalendarType, ""}, } { - assert.Equal(test.expect, FormatFromMediaType(test.m), fmt.Sprintf("t%d", i)) + c.Assert(FormatFromMediaType(test.m), qt.Equals, test.expect) } } func TestFormatFromFrontMatterType(t *testing.T) { - assert := require.New(t) - for i, test := range []struct { + c := qt.New(t) + for _, test := range []struct { typ pageparser.ItemType expect Format }{ @@ -70,13 +69,13 @@ func TestFormatFromFrontMatterType(t *testing.T) { {pageparser.TypeFrontMatterORG, ORG}, {pageparser.TypeIgnore, ""}, } { - assert.Equal(test.expect, FormatFromFrontMatterType(test.typ), fmt.Sprintf("t%d", i)) + c.Assert(FormatFromFrontMatterType(test.typ), qt.Equals, test.expect) } } func TestFormatFromContentString(t *testing.T) { t.Parallel() - assert := require.New(t) + c := qt.New(t) for i, test := range []struct { data string @@ -92,10 +91,10 @@ func TestFormatFromContentString(t *testing.T) { {`asdfasdf`, Format("")}, {``, Format("")}, } { - errMsg := fmt.Sprintf("[%d] %s", i, test.data) + errMsg := qt.Commentf("[%d] %s", i, test.data) result := Default.FormatFromContentString(test.data) - assert.Equal(test.expect, result, errMsg) + c.Assert(result, qt.Equals, test.expect, errMsg) } } diff --git a/parser/pageparser/pagelexer_test.go b/parser/pageparser/pagelexer_test.go index 70def3091..3bc3bf6ad 100644 --- a/parser/pageparser/pagelexer_test.go +++ b/parser/pageparser/pagelexer_test.go @@ -16,14 +16,14 @@ package pageparser import ( "testing" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) func TestMinIndex(t *testing.T) { - assert := require.New(t) - assert.Equal(1, minIndex(4, 1, 2, 3)) - assert.Equal(0, minIndex(4, 0, -2, 2, 5)) - assert.Equal(-1, minIndex()) - assert.Equal(-1, minIndex(-2, -3)) + c := qt.New(t) + c.Assert(minIndex(4, 1, 2, 3), qt.Equals, 1) + c.Assert(minIndex(4, 0, -2, 2, 5), qt.Equals, 0) + c.Assert(minIndex(), qt.Equals, -1) + c.Assert(minIndex(-2, -3), qt.Equals, -1) } |