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 /helpers/general_test.go | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) | |
download | hugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip |
tests: Convert from testify to quicktest
Diffstat (limited to 'helpers/general_test.go')
-rw-r--r-- | helpers/general_test.go | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/helpers/general_test.go b/helpers/general_test.go index dd61d8948..e5e5e56ed 100644 --- a/helpers/general_test.go +++ b/helpers/general_test.go @@ -19,9 +19,8 @@ import ( "strings" "testing" + qt "github.com/frankban/quicktest" "github.com/spf13/afero" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestGuessType(t *testing.T) { @@ -188,6 +187,7 @@ func TestSliceToLower(t *testing.T) { } func TestReaderContains(t *testing.T) { + c := qt.New(t) for i, this := range append(containsBenchTestData, containsAdditionalTestData...) { result := ReaderContains(strings.NewReader(this.v1), this.v2) if result != this.expect { @@ -195,21 +195,21 @@ func TestReaderContains(t *testing.T) { } } - assert.False(t, ReaderContains(nil, []byte("a"))) - assert.False(t, ReaderContains(nil, nil)) + c.Assert(ReaderContains(nil, []byte("a")), qt.Equals, false) + c.Assert(ReaderContains(nil, nil), qt.Equals, false) } func TestGetTitleFunc(t *testing.T) { title := "somewhere over the rainbow" - assert := require.New(t) + c := qt.New(t) - assert.Equal("Somewhere Over The Rainbow", GetTitleFunc("go")(title)) - assert.Equal("Somewhere over the Rainbow", GetTitleFunc("chicago")(title), "Chicago style") - assert.Equal("Somewhere over the Rainbow", GetTitleFunc("Chicago")(title), "Chicago style") - assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style") - assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style") - assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("")(title), "AP style") - assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("unknown")(title), "AP style") + c.Assert(GetTitleFunc("go")(title), qt.Equals, "Somewhere Over The Rainbow") + c.Assert(GetTitleFunc("chicago")(title), qt.Equals, "Somewhere over the Rainbow") + c.Assert(GetTitleFunc("Chicago")(title), qt.Equals, "Somewhere over the Rainbow") + c.Assert(GetTitleFunc("ap")(title), qt.Equals, "Somewhere Over the Rainbow") + c.Assert(GetTitleFunc("ap")(title), qt.Equals, "Somewhere Over the Rainbow") + c.Assert(GetTitleFunc("")(title), qt.Equals, "Somewhere Over the Rainbow") + c.Assert(GetTitleFunc("unknown")(title), qt.Equals, "Somewhere Over the Rainbow") } @@ -244,19 +244,20 @@ func TestUniqueStringsReuse(t *testing.T) { } func TestUniqueStringsSorted(t *testing.T) { - assert := require.New(t) + c := qt.New(t) in := []string{"a", "a", "b", "c", "b", "", "a", "", "d"} output := UniqueStringsSorted(in) expected := []string{"", "a", "b", "c", "d"} - assert.Equal(expected, output) - assert.Nil(UniqueStringsSorted(nil)) + c.Assert(output, qt.DeepEquals, expected) + c.Assert(UniqueStringsSorted(nil), qt.IsNil) } func TestFindAvailablePort(t *testing.T) { + c := qt.New(t) addr, err := FindAvailablePort() - assert.Nil(t, err) - assert.NotNil(t, addr) - assert.True(t, addr.Port > 0) + c.Assert(err, qt.IsNil) + c.Assert(addr, qt.Not(qt.IsNil)) + c.Assert(addr.Port > 0, qt.Equals, true) } func TestFastMD5FromFile(t *testing.T) { @@ -278,17 +279,17 @@ func TestFastMD5FromFile(t *testing.T) { t.Fatal(err) } - req := require.New(t) + c := qt.New(t) sf1, err := fs.Open("small.txt") - req.NoError(err) + c.Assert(err, qt.IsNil) sf2, err := fs.Open("small2.txt") - req.NoError(err) + c.Assert(err, qt.IsNil) bf1, err := fs.Open("bigger.txt") - req.NoError(err) + c.Assert(err, qt.IsNil) bf2, err := fs.Open("bigger2.txt") - req.NoError(err) + c.Assert(err, qt.IsNil) defer sf1.Close() defer sf2.Close() @@ -296,24 +297,24 @@ func TestFastMD5FromFile(t *testing.T) { defer bf2.Close() m1, err := MD5FromFileFast(sf1) - req.NoError(err) - req.Equal("e9c8989b64b71a88b4efb66ad05eea96", m1) + c.Assert(err, qt.IsNil) + c.Assert(m1, qt.Equals, "e9c8989b64b71a88b4efb66ad05eea96") m2, err := MD5FromFileFast(sf2) - req.NoError(err) - req.NotEqual(m1, m2) + c.Assert(err, qt.IsNil) + c.Assert(m2, qt.Not(qt.Equals), m1) m3, err := MD5FromFileFast(bf1) - req.NoError(err) - req.NotEqual(m2, m3) + c.Assert(err, qt.IsNil) + c.Assert(m3, qt.Not(qt.Equals), m2) m4, err := MD5FromFileFast(bf2) - req.NoError(err) - req.NotEqual(m3, m4) + c.Assert(err, qt.IsNil) + c.Assert(m4, qt.Not(qt.Equals), m3) m5, err := MD5FromReader(bf2) - req.NoError(err) - req.NotEqual(m4, m5) + c.Assert(err, qt.IsNil) + c.Assert(m5, qt.Not(qt.Equals), m4) } func BenchmarkMD5FromFileFast(b *testing.B) { |