diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-08-10 21:05:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-08-12 13:26:32 +0200 |
commit | 9e571827055dedb46b78c5db3d17d6913f14870b (patch) | |
tree | f5f0108afe0c9385ff6dc27664943d9f719f57ad /lazy | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) | |
download | hugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip |
tests: Convert from testify to quicktest
Diffstat (limited to 'lazy')
-rw-r--r-- | lazy/init_test.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lazy/init_test.go b/lazy/init_test.go index ea1b22fe9..772081b56 100644 --- a/lazy/init_test.go +++ b/lazy/init_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) var ( @@ -44,7 +44,7 @@ func doWorkOfSize(size int) { } func TestInit(t *testing.T) { - assert := require.New(t) + c := qt.New(t) var result string @@ -84,33 +84,33 @@ func TestInit(t *testing.T) { var err error if rnd.Intn(10) < 5 { _, err = root.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) } // Add a new branch on the fly. if rnd.Intn(10) > 5 { branch := branch1_2.Branch(f2()) _, err = branch.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) } else { _, err = branch1_2_1.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) } _, err = branch1_2.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) }(i) wg.Wait() - assert.Equal("root(1)|root(2)|branch_1|branch_1_1|branch_1_2|branch_1_2_1|", result) + c.Assert(result, qt.Equals, "root(1)|root(2)|branch_1|branch_1_1|branch_1_2|branch_1_2_1|") } } func TestInitAddWithTimeout(t *testing.T) { - assert := require.New(t) + c := qt.New(t) init := New().AddWithTimeout(100*time.Millisecond, func(ctx context.Context) (interface{}, error) { return nil, nil @@ -118,11 +118,11 @@ func TestInitAddWithTimeout(t *testing.T) { _, err := init.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) } func TestInitAddWithTimeoutTimeout(t *testing.T) { - assert := require.New(t) + c := qt.New(t) init := New().AddWithTimeout(100*time.Millisecond, func(ctx context.Context) (interface{}, error) { time.Sleep(500 * time.Millisecond) @@ -137,16 +137,16 @@ func TestInitAddWithTimeoutTimeout(t *testing.T) { _, err := init.Do() - assert.Error(err) + c.Assert(err, qt.Not(qt.IsNil)) - assert.Contains(err.Error(), "timed out") + c.Assert(err.Error(), qt.Contains, "timed out") time.Sleep(1 * time.Second) } func TestInitAddWithTimeoutError(t *testing.T) { - assert := require.New(t) + c := qt.New(t) init := New().AddWithTimeout(100*time.Millisecond, func(ctx context.Context) (interface{}, error) { return nil, errors.New("failed") @@ -154,7 +154,7 @@ func TestInitAddWithTimeoutError(t *testing.T) { _, err := init.Do() - assert.Error(err) + c.Assert(err, qt.Not(qt.IsNil)) } type T struct { @@ -177,7 +177,7 @@ func (t *T) Add2(v string) { // https://github.com/gohugoio/hugo/issues/5901 func TestInitBranchOrder(t *testing.T) { - assert := require.New(t) + c := qt.New(t) base := New() @@ -216,11 +216,11 @@ func TestInitBranchOrder(t *testing.T) { go func() { defer wg.Done() _, err := v.Do() - assert.NoError(err) + c.Assert(err, qt.IsNil) }() } wg.Wait() - assert.Equal("ABAB", state.V2) + c.Assert(state.V2, qt.Equals, "ABAB") } |