From 9e571827055dedb46b78c5db3d17d6913f14870b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 10 Aug 2019 21:05:17 +0200 Subject: tests: Convert from testify to quicktest --- tpl/crypto/crypto_test.go | 33 ++++++++++++++++----------------- tpl/crypto/init_test.go | 8 +++++--- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'tpl/crypto') diff --git a/tpl/crypto/crypto_test.go b/tpl/crypto/crypto_test.go index 1bd919c31..209ef9f0a 100644 --- a/tpl/crypto/crypto_test.go +++ b/tpl/crypto/crypto_test.go @@ -14,15 +14,14 @@ package crypto import ( - "fmt" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) func TestMD5(t *testing.T) { t.Parallel() + c := qt.New(t) ns := New() @@ -34,23 +33,23 @@ func TestMD5(t *testing.T) { {"Lorem ipsum dolor", "06ce65ac476fc656bea3fca5d02cfd81"}, {t, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test.in) + errMsg := qt.Commentf("[%d] %v", i, test.in) result, err := ns.MD5(test.in) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil, errMsg) + c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestSHA1(t *testing.T) { t.Parallel() - + c := qt.New(t) ns := New() for i, test := range []struct { @@ -61,23 +60,23 @@ func TestSHA1(t *testing.T) { {"Lorem ipsum dolor", "45f75b844be4d17b3394c6701768daf39419c99b"}, {t, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test.in) + errMsg := qt.Commentf("[%d] %v", i, test.in) result, err := ns.SHA1(test.in) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil, errMsg) + c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestSHA256(t *testing.T) { t.Parallel() - + c := qt.New(t) ns := New() for i, test := range []struct { @@ -88,16 +87,16 @@ func TestSHA256(t *testing.T) { {"Lorem ipsum dolor", "9b3e1beb7053e0f900a674dd1c99aca3355e1275e1b03d3cb1bc977f5154e196"}, {t, false}, } { - errMsg := fmt.Sprintf("[%d] %v", i, test.in) + errMsg := qt.Commentf("[%d] %v", i, test.in) result, err := ns.SHA256(test.in) if b, ok := test.expect.(bool); ok && !b { - require.Error(t, err, errMsg) + c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } - require.NoError(t, err, errMsg) - assert.Equal(t, test.expect, result, errMsg) + c.Assert(err, qt.IsNil, errMsg) + c.Assert(result, qt.Equals, test.expect, errMsg) } } diff --git a/tpl/crypto/init_test.go b/tpl/crypto/init_test.go index 852a90a40..120e1e4e7 100644 --- a/tpl/crypto/init_test.go +++ b/tpl/crypto/init_test.go @@ -16,12 +16,14 @@ package crypto 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{}) } -- cgit v1.2.3