diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-10 21:05:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-12 13:26:32 +0200 |
commit | 9e571827055dedb46b78c5db3d17d6913f14870b (patch) | |
tree | f5f0108afe0c9385ff6dc27664943d9f719f57ad /tpl/compare | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) |
tests: Convert from testify to quicktest
Diffstat (limited to 'tpl/compare')
-rw-r--r-- | tpl/compare/compare_test.go | 28 | ||||
-rw-r--r-- | tpl/compare/init_test.go | 8 | ||||
-rw-r--r-- | tpl/compare/truth_test.go | 12 |
3 files changed, 27 insertions, 21 deletions
diff --git a/tpl/compare/compare_test.go b/tpl/compare/compare_test.go index a7b1e54a6..2331206b3 100644 --- a/tpl/compare/compare_test.go +++ b/tpl/compare/compare_test.go @@ -14,17 +14,17 @@ package compare import ( - "fmt" "path" "reflect" "runtime" "testing" "time" + "github.com/gohugoio/hugo/htesting/hqt" + + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/hugo" "github.com/spf13/cast" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type T struct { @@ -80,6 +80,7 @@ func tstIsLt(tp tstCompareType) bool { return tp == tstLt || tp == tstLe } func TestDefaultFunc(t *testing.T) { t.Parallel() + c := qt.New(t) then := time.Now() now := time.Now() @@ -127,12 +128,15 @@ func TestDefaultFunc(t *testing.T) { {then, now, now}, {then, time.Time{}, then}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) + + eq := qt.CmpEquals(hqt.DeepAllowUnexported(test.dflt)) + + errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Default(test.dflt, test.given) - require.NoError(t, err, errMsg) - assert.Equal(t, result, test.expect, errMsg) + c.Assert(err, qt.IsNil, errMsg) + c.Assert(result, eq, test.expect, errMsg) } } @@ -234,11 +238,11 @@ func doTestCompare(t *testing.T, tp tstCompareType, funcUnderTest func(a, b inte } func TestCase(t *testing.T) { - assert := require.New(t) + c := qt.New(t) n := New(true) - assert.True(n.Lt("az", "Za")) - assert.True(n.Gt("ab", "Ab")) + c.Assert(n.Lt("az", "Za"), qt.Equals, true) + c.Assert(n.Gt("ab", "Ab"), qt.Equals, true) } func TestTimeUnix(t *testing.T) { @@ -265,10 +269,10 @@ func TestTimeUnix(t *testing.T) { } func TestConditional(t *testing.T) { - assert := require.New(t) + c := qt.New(t) n := New(false) a, b := "a", "b" - assert.Equal(a, n.Conditional(true, a, b)) - assert.Equal(b, n.Conditional(false, a, b)) + c.Assert(n.Conditional(true, a, b), qt.Equals, a) + c.Assert(n.Conditional(false, a, b), qt.Equals, b) } diff --git a/tpl/compare/init_test.go b/tpl/compare/init_test.go index 65e59b1aa..29a525f93 100644 --- a/tpl/compare/init_test.go +++ b/tpl/compare/init_test.go @@ -16,12 +16,14 @@ package compare import ( "testing" + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" + "github.com/gohugoio/hugo/htesting/hqt" "github.com/gohugoio/hugo/tpl/internal" - "github.com/stretchr/testify/require" ) func TestInit(t *testing.T) { + c := qt.New(t) var found bool var ns *internal.TemplateFuncsNamespace @@ -33,6 +35,6 @@ func TestInit(t *testing.T) { } } - require.True(t, found) - require.IsType(t, &Namespace{}, ns.Context()) + c.Assert(found, qt.Equals, true) + c.Assert(ns.Context(), hqt.IsSameType, &Namespace{}) } diff --git a/tpl/compare/truth_test.go b/tpl/compare/truth_test.go index 7a9d03442..4c83e8b0a 100644 --- a/tpl/compare/truth_test.go +++ b/tpl/compare/truth_test.go @@ -18,8 +18,8 @@ import ( "testing" "time" + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/hreflect" - "github.com/stretchr/testify/require" ) func TestTruth(t *testing.T) { @@ -46,15 +46,15 @@ func TestTruth(t *testing.T) { }) t.Run("Not", func(t *testing.T) { - assert := require.New(t) - assert.True(n.Not(falsev)) - assert.False(n.Not(truthv)) + c := qt.New(t) + c.Assert(n.Not(falsev), qt.Equals, true) + c.Assert(n.Not(truthv), qt.Equals, false) }) t.Run("getIf", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) assertTruth(t, n.getIf(reflect.ValueOf(nil)), false) s := reflect.ValueOf("Hugo") - assert.Equal(s, n.getIf(s)) + c.Assert(n.getIf(s), qt.Equals, s) }) } |