diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-10 22:05:17 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-12 14:26:32 +0300 |
commit | 9e571827055dedb46b78c5db3d17d6913f14870b (patch) | |
tree | f5f0108afe0c9385ff6dc27664943d9f719f57ad /tpl/path | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) |
tests: Convert from testify to quicktest
Diffstat (limited to 'tpl/path')
-rw-r--r-- | tpl/path/init_test.go | 9 | ||||
-rw-r--r-- | tpl/path/path_test.go | 54 |
2 files changed, 32 insertions, 31 deletions
diff --git a/tpl/path/init_test.go b/tpl/path/init_test.go index b0aeab358..20744b239 100644 --- a/tpl/path/init_test.go +++ b/tpl/path/init_test.go @@ -16,12 +16,15 @@ package path import ( "testing" + "github.com/gohugoio/hugo/htesting/hqt" + + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "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 +36,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/path/path_test.go b/tpl/path/path_test.go index b9a29a285..ce453b9a1 100644 --- a/tpl/path/path_test.go +++ b/tpl/path/path_test.go @@ -14,14 +14,12 @@ package path import ( - "fmt" "path/filepath" "testing" + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/spf13/viper" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var ns = New(&deps.Deps{Cfg: viper.New()}) @@ -30,8 +28,9 @@ type tstNoStringer struct{} func TestBase(t *testing.T) { t.Parallel() + c := qt.New(t) - for i, test := range []struct { + for _, test := range []struct { path interface{} expect interface{} }{ @@ -44,24 +43,24 @@ func TestBase(t *testing.T) { // errors {tstNoStringer{}, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) result, err := ns.Base(test.path) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil)) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil) + c.Assert(result, qt.Equals, test.expect) } } func TestDir(t *testing.T) { t.Parallel() + c := qt.New(t) - for i, test := range []struct { + for _, test := range []struct { path interface{} expect interface{} }{ @@ -74,24 +73,24 @@ func TestDir(t *testing.T) { // errors {tstNoStringer{}, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) result, err := ns.Dir(test.path) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil)) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil) + c.Assert(result, qt.Equals, test.expect) } } func TestExt(t *testing.T) { t.Parallel() + c := qt.New(t) - for i, test := range []struct { + for _, test := range []struct { path interface{} expect interface{} }{ @@ -102,24 +101,24 @@ func TestExt(t *testing.T) { // errors {tstNoStringer{}, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) result, err := ns.Ext(test.path) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil)) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil) + c.Assert(result, qt.Equals, test.expect) } } func TestJoin(t *testing.T) { t.Parallel() + c := qt.New(t) - for i, test := range []struct { + for _, test := range []struct { elements interface{} expect interface{} }{ @@ -136,24 +135,24 @@ func TestJoin(t *testing.T) { {tstNoStringer{}, false}, {[]interface{}{"", tstNoStringer{}}, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) result, err := ns.Join(test.elements) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil)) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil) + c.Assert(result, qt.Equals, test.expect) } } func TestSplit(t *testing.T) { t.Parallel() + c := qt.New(t) - for i, test := range []struct { + for _, test := range []struct { path interface{} expect interface{} }{ @@ -164,16 +163,15 @@ func TestSplit(t *testing.T) { // errors {tstNoStringer{}, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test) result, err := ns.Split(test.path) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil)) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil) + c.Assert(result, qt.Equals, test.expect) } } |