aboutsummaryrefslogtreecommitdiffhomepage
path: root/common/herrors
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-08-10 21:05:17 +0200
committerBjørn Erik Pedersen <[email protected]>2019-08-12 13:26:32 +0200
commit9e571827055dedb46b78c5db3d17d6913f14870b (patch)
treef5f0108afe0c9385ff6dc27664943d9f719f57ad /common/herrors
parent6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff)
downloadhugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz
hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip
tests: Convert from testify to quicktest
Diffstat (limited to 'common/herrors')
-rw-r--r--common/herrors/error_locator_test.go54
-rw-r--r--common/herrors/file_error_test.go17
2 files changed, 35 insertions, 36 deletions
diff --git a/common/herrors/error_locator_test.go b/common/herrors/error_locator_test.go
index 2d007016d..cce94166f 100644
--- a/common/herrors/error_locator_test.go
+++ b/common/herrors/error_locator_test.go
@@ -18,11 +18,11 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/require"
+ qt "github.com/frankban/quicktest"
)
func TestErrorLocator(t *testing.T) {
- assert := require.New(t)
+ c := qt.New(t)
lineMatcher := func(m LineMatcher) bool {
return strings.Contains(m.Line, "THEONE")
@@ -39,45 +39,45 @@ LINE 8
`
location := locateErrorInString(lines, lineMatcher)
- assert.Equal([]string{"LINE 3", "LINE 4", "This is THEONE", "LINE 6", "LINE 7"}, location.Lines)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"LINE 3", "LINE 4", "This is THEONE", "LINE 6", "LINE 7"})
pos := location.Position()
- assert.Equal(5, pos.LineNumber)
- assert.Equal(2, location.LinesPos)
+ c.Assert(pos.LineNumber, qt.Equals, 5)
+ c.Assert(location.LinesPos, qt.Equals, 2)
- assert.Equal([]string{"This is THEONE"}, locateErrorInString(`This is THEONE`, lineMatcher).Lines)
+ c.Assert(locateErrorInString(`This is THEONE`, lineMatcher).Lines, qt.DeepEquals, []string{"This is THEONE"})
location = locateErrorInString(`L1
This is THEONE
L2
`, lineMatcher)
- assert.Equal(2, location.Position().LineNumber)
- assert.Equal(1, location.LinesPos)
- assert.Equal([]string{"L1", "This is THEONE", "L2", ""}, location.Lines)
+ c.Assert(location.Position().LineNumber, qt.Equals, 2)
+ c.Assert(location.LinesPos, qt.Equals, 1)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"L1", "This is THEONE", "L2", ""})
location = locateErrorInString(`This is THEONE
L2
`, lineMatcher)
- assert.Equal(0, location.LinesPos)
- assert.Equal([]string{"This is THEONE", "L2", ""}, location.Lines)
+ c.Assert(location.LinesPos, qt.Equals, 0)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"This is THEONE", "L2", ""})
location = locateErrorInString(`L1
This THEONE
`, lineMatcher)
- assert.Equal([]string{"L1", "This THEONE", ""}, location.Lines)
- assert.Equal(1, location.LinesPos)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"L1", "This THEONE", ""})
+ c.Assert(location.LinesPos, qt.Equals, 1)
location = locateErrorInString(`L1
L2
This THEONE
`, lineMatcher)
- assert.Equal([]string{"L1", "L2", "This THEONE", ""}, location.Lines)
- assert.Equal(2, location.LinesPos)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"L1", "L2", "This THEONE", ""})
+ c.Assert(location.LinesPos, qt.Equals, 2)
location = locateErrorInString("NO MATCH", lineMatcher)
- assert.Equal(-1, location.Position().LineNumber)
- assert.Equal(-1, location.LinesPos)
- assert.Equal(0, len(location.Lines))
+ c.Assert(location.Position().LineNumber, qt.Equals, -1)
+ c.Assert(location.LinesPos, qt.Equals, -1)
+ c.Assert(len(location.Lines), qt.Equals, 0)
lineMatcher = func(m LineMatcher) bool {
return m.LineNumber == 6
@@ -94,9 +94,9 @@ H
I
J`, lineMatcher)
- assert.Equal([]string{"D", "E", "F", "G", "H"}, location.Lines)
- assert.Equal(6, location.Position().LineNumber)
- assert.Equal(2, location.LinesPos)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"D", "E", "F", "G", "H"})
+ c.Assert(location.Position().LineNumber, qt.Equals, 6)
+ c.Assert(location.LinesPos, qt.Equals, 2)
// Test match EOF
lineMatcher = func(m LineMatcher) bool {
@@ -108,9 +108,9 @@ B
C
`, lineMatcher)
- assert.Equal([]string{"B", "C", ""}, location.Lines)
- assert.Equal(4, location.Position().LineNumber)
- assert.Equal(2, location.LinesPos)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"B", "C", ""})
+ c.Assert(location.Position().LineNumber, qt.Equals, 4)
+ c.Assert(location.LinesPos, qt.Equals, 2)
offsetMatcher := func(m LineMatcher) bool {
return m.Offset == 1
@@ -122,8 +122,8 @@ C
D
E`, offsetMatcher)
- assert.Equal([]string{"A", "B", "C", "D"}, location.Lines)
- assert.Equal(2, location.Position().LineNumber)
- assert.Equal(1, location.LinesPos)
+ c.Assert(location.Lines, qt.DeepEquals, []string{"A", "B", "C", "D"})
+ c.Assert(location.Position().LineNumber, qt.Equals, 2)
+ c.Assert(location.LinesPos, qt.Equals, 1)
}
diff --git a/common/herrors/file_error_test.go b/common/herrors/file_error_test.go
index 4108983d3..b1b5c5a02 100644
--- a/common/herrors/file_error_test.go
+++ b/common/herrors/file_error_test.go
@@ -14,18 +14,17 @@
package herrors
import (
- "fmt"
"testing"
"github.com/pkg/errors"
- "github.com/stretchr/testify/require"
+ qt "github.com/frankban/quicktest"
)
func TestToLineNumberError(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
for i, test := range []struct {
in error
@@ -43,15 +42,15 @@ func TestToLineNumberError(t *testing.T) {
got := ToFileError("template", test.in)
- errMsg := fmt.Sprintf("[%d][%T]", i, got)
+ errMsg := qt.Commentf("[%d][%T]", i, got)
le, ok := got.(FileError)
- assert.True(ok)
+ c.Assert(ok, qt.Equals, true)
- assert.True(ok, errMsg)
+ c.Assert(ok, qt.Equals, true, errMsg)
pos := le.Position()
- assert.Equal(test.lineNumber, pos.LineNumber, errMsg)
- assert.Equal(test.columnNumber, pos.ColumnNumber, errMsg)
- assert.Error(errors.Cause(got))
+ c.Assert(pos.LineNumber, qt.Equals, test.lineNumber, errMsg)
+ c.Assert(pos.ColumnNumber, qt.Equals, test.columnNumber, errMsg)
+ c.Assert(errors.Cause(got), qt.Not(qt.IsNil))
}
}