Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl/cast
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-10 22:05:17 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-12 14:26:32 +0300
commit9e571827055dedb46b78c5db3d17d6913f14870b (patch)
treef5f0108afe0c9385ff6dc27664943d9f719f57ad /tpl/cast
parent6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff)
tests: Convert from testify to quicktest
Diffstat (limited to 'tpl/cast')
-rw-r--r--tpl/cast/cast_test.go33
-rw-r--r--tpl/cast/init_test.go10
2 files changed, 23 insertions, 20 deletions
diff --git a/tpl/cast/cast_test.go b/tpl/cast/cast_test.go
index fc20934f8..c6219728b 100644
--- a/tpl/cast/cast_test.go
+++ b/tpl/cast/cast_test.go
@@ -14,16 +14,15 @@
package cast
import (
- "fmt"
"html/template"
"testing"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
+ qt "github.com/frankban/quicktest"
)
func TestToInt(t *testing.T) {
t.Parallel()
+ c := qt.New(t)
ns := New()
@@ -40,23 +39,23 @@ func TestToInt(t *testing.T) {
{"a", false},
{t, false},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test.v)
+ errMsg := qt.Commentf("[%d] %v", i, test.v)
result, err := ns.ToInt(test.v)
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 TestToString(t *testing.T) {
t.Parallel()
-
+ c := qt.New(t)
ns := New()
for i, test := range []struct {
@@ -68,23 +67,23 @@ func TestToString(t *testing.T) {
{"a", "a"},
{t, false},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test.v)
+ errMsg := qt.Commentf("[%d] %v", i, test.v)
result, err := ns.ToString(test.v)
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 TestToFloat(t *testing.T) {
t.Parallel()
-
+ c := qt.New(t)
ns := New()
for i, test := range []struct {
@@ -105,16 +104,16 @@ func TestToFloat(t *testing.T) {
{2, 2.0},
{t, false},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test.v)
+ errMsg := qt.Commentf("[%d] %v", i, test.v)
result, err := ns.ToFloat(test.v)
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/cast/init_test.go b/tpl/cast/init_test.go
index 47cbd3d0b..73d9d5adc 100644
--- a/tpl/cast/init_test.go
+++ b/tpl/cast/init_test.go
@@ -16,12 +16,15 @@ package cast
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,7 @@ 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{})
+
}