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 /related | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) | |
download | hugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip |
tests: Convert from testify to quicktest
Diffstat (limited to 'related')
-rw-r--r-- | related/inverted_index_test.go | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/related/inverted_index_test.go b/related/inverted_index_test.go index 4ef27875d..57e722364 100644 --- a/related/inverted_index_test.go +++ b/related/inverted_index_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" + qt "github.com/frankban/quicktest" ) type testDoc struct { @@ -109,75 +109,75 @@ func TestSearch(t *testing.T) { idx.Add(docs...) t.Run("count", func(t *testing.T) { - assert := require.New(t) - assert.Len(idx.index, 2) + c := qt.New(t) + c.Assert(len(idx.index), qt.Equals, 2) set1, found := idx.index["tags"] - assert.True(found) + c.Assert(found, qt.Equals, true) // 6 tags - assert.Len(set1, 6) + c.Assert(len(set1), qt.Equals, 6) set2, found := idx.index["keywords"] - assert.True(found) - assert.Len(set2, 2) + c.Assert(found, qt.Equals, true) + c.Assert(len(set2), qt.Equals, 2) }) t.Run("search-tags", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) m, err := idx.search(newQueryElement("tags", StringsToKeywords("a", "b", "d", "z")...)) - assert.NoError(err) - assert.Len(m, 2) - assert.Equal(docs[0], m[0]) - assert.Equal(docs[1], m[1]) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 2) + c.Assert(m[0], qt.Equals, docs[0]) + c.Assert(m[1], qt.Equals, docs[1]) }) t.Run("search-tags-and-keywords", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) m, err := idx.search( newQueryElement("tags", StringsToKeywords("a", "b", "z")...), newQueryElement("keywords", StringsToKeywords("a", "b")...)) - assert.NoError(err) - assert.Len(m, 3) - assert.Equal(docs[3], m[0]) - assert.Equal(docs[2], m[1]) - assert.Equal(docs[0], m[2]) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 3) + c.Assert(m[0], qt.Equals, docs[3]) + c.Assert(m[1], qt.Equals, docs[2]) + c.Assert(m[2], qt.Equals, docs[0]) }) t.Run("searchdoc-all", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) doc := newTestDoc("tags", "a").addKeywords("keywords", "a") m, err := idx.SearchDoc(doc) - assert.NoError(err) - assert.Len(m, 2) - assert.Equal(docs[3], m[0]) - assert.Equal(docs[2], m[1]) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 2) + c.Assert(m[0], qt.Equals, docs[3]) + c.Assert(m[1], qt.Equals, docs[2]) }) t.Run("searchdoc-tags", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) doc := newTestDoc("tags", "a", "b", "d", "z").addKeywords("keywords", "a", "b") m, err := idx.SearchDoc(doc, "tags") - assert.NoError(err) - assert.Len(m, 2) - assert.Equal(docs[0], m[0]) - assert.Equal(docs[1], m[1]) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 2) + c.Assert(m[0], qt.Equals, docs[0]) + c.Assert(m[1], qt.Equals, docs[1]) }) t.Run("searchdoc-keywords-date", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) doc := newTestDoc("tags", "a", "b", "d", "z").addKeywords("keywords", "a", "b") // This will get a date newer than the others. newDoc := newTestDoc("keywords", "a", "b") idx.Add(newDoc) m, err := idx.SearchDoc(doc, "keywords") - assert.NoError(err) - assert.Len(m, 2) - assert.Equal(docs[3], m[0]) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 2) + c.Assert(m[0], qt.Equals, docs[3]) }) t.Run("searchdoc-keywords-same-date", func(t *testing.T) { - assert := require.New(t) + c := qt.New(t) idx := NewInvertedIndex(config) date := time.Now() @@ -192,10 +192,10 @@ func TestSearch(t *testing.T) { } m, err := idx.SearchDoc(doc, "keywords") - assert.NoError(err) - assert.Len(m, 10) + c.Assert(err, qt.IsNil) + c.Assert(len(m), qt.Equals, 10) for i := 0; i < 10; i++ { - assert.Equal(fmt.Sprintf("doc%d", i), m[i].Name()) + c.Assert(m[i].Name(), qt.Equals, fmt.Sprintf("doc%d", i)) } }) |