summaryrefslogtreecommitdiffstats
path: root/common/maps/scratch_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-10 21:05:17 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-12 13:26:32 +0200
commit9e571827055dedb46b78c5db3d17d6913f14870b (patch)
treef5f0108afe0c9385ff6dc27664943d9f719f57ad /common/maps/scratch_test.go
parent6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff)
tests: Convert from testify to quicktest
Diffstat (limited to 'common/maps/scratch_test.go')
-rw-r--r--common/maps/scratch_test.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/common/maps/scratch_test.go b/common/maps/scratch_test.go
index 4550a22c5..c2c436e40 100644
--- a/common/maps/scratch_test.go
+++ b/common/maps/scratch_test.go
@@ -18,31 +18,31 @@ import (
"sync"
"testing"
- "github.com/stretchr/testify/require"
+ qt "github.com/frankban/quicktest"
)
func TestScratchAdd(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.Add("int1", 10)
scratch.Add("int1", 20)
scratch.Add("int2", 20)
- assert.Equal(int64(30), scratch.Get("int1"))
- assert.Equal(20, scratch.Get("int2"))
+ c.Assert(scratch.Get("int1"), qt.Equals, int64(30))
+ c.Assert(scratch.Get("int2"), qt.Equals, 20)
scratch.Add("float1", float64(10.5))
scratch.Add("float1", float64(20.1))
- assert.Equal(float64(30.6), scratch.Get("float1"))
+ c.Assert(scratch.Get("float1"), qt.Equals, float64(30.6))
scratch.Add("string1", "Hello ")
scratch.Add("string1", "big ")
scratch.Add("string1", "World!")
- assert.Equal("Hello big World!", scratch.Get("string1"))
+ c.Assert(scratch.Get("string1"), qt.Equals, "Hello big World!")
scratch.Add("scratch", scratch)
_, err := scratch.Add("scratch", scratch)
@@ -55,14 +55,14 @@ func TestScratchAdd(t *testing.T) {
func TestScratchAddSlice(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
_, err := scratch.Add("intSlice", []int{1, 2})
- assert.NoError(err)
+ c.Assert(err, qt.IsNil)
_, err = scratch.Add("intSlice", 3)
- assert.NoError(err)
+ c.Assert(err, qt.IsNil)
sl := scratch.Get("intSlice")
expected := []int{1, 2, 3}
@@ -72,7 +72,7 @@ func TestScratchAddSlice(t *testing.T) {
}
_, err = scratch.Add("intSlice", []int{4, 5})
- assert.NoError(err)
+ c.Assert(err, qt.IsNil)
sl = scratch.Get("intSlice")
expected = []int{1, 2, 3, 4, 5}
@@ -85,49 +85,49 @@ func TestScratchAddSlice(t *testing.T) {
// https://github.com/gohugoio/hugo/issues/5275
func TestScratchAddTypedSliceToInterfaceSlice(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.Set("slice", []interface{}{})
_, err := scratch.Add("slice", []int{1, 2})
- assert.NoError(err)
- assert.Equal([]int{1, 2}, scratch.Get("slice"))
+ c.Assert(err, qt.IsNil)
+ c.Assert(scratch.Get("slice"), qt.DeepEquals, []int{1, 2})
}
// https://github.com/gohugoio/hugo/issues/5361
func TestScratchAddDifferentTypedSliceToInterfaceSlice(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.Set("slice", []string{"foo"})
_, err := scratch.Add("slice", []int{1, 2})
- assert.NoError(err)
- assert.Equal([]interface{}{"foo", 1, 2}, scratch.Get("slice"))
+ c.Assert(err, qt.IsNil)
+ c.Assert(scratch.Get("slice"), qt.DeepEquals, []interface{}{"foo", 1, 2})
}
func TestScratchSet(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.Set("key", "val")
- assert.Equal("val", scratch.Get("key"))
+ c.Assert(scratch.Get("key"), qt.Equals, "val")
}
func TestScratchDelete(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.Set("key", "val")
scratch.Delete("key")
scratch.Add("key", "Lucy Parsons")
- assert.Equal("Lucy Parsons", scratch.Get("key"))
+ c.Assert(scratch.Get("key"), qt.Equals, "Lucy Parsons")
}
// Issue #2005
@@ -177,7 +177,7 @@ func TestScratchGet(t *testing.T) {
func TestScratchSetInMap(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
scratch := NewScratch()
scratch.SetInMap("key", "lux", "Lux")
@@ -185,7 +185,7 @@ func TestScratchSetInMap(t *testing.T) {
scratch.SetInMap("key", "zyx", "Zyx")
scratch.SetInMap("key", "abc", "Abc (updated)")
scratch.SetInMap("key", "def", "Def")
- assert.Equal([]interface{}{0: "Abc (updated)", 1: "Def", 2: "Lux", 3: "Zyx"}, scratch.GetSortedMapValues("key"))
+ c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []interface{}{0: "Abc (updated)", 1: "Def", 2: "Lux", 3: "Zyx"})
}
func TestScratchGetSortedMapValues(t *testing.T) {