|
|
|
|
@@ -262,6 +262,11 @@ var searchPostStoreTests = []searchTest{
|
|
|
|
|
Fn: testShouldNotReturnLinksEmbeddedInMarkdown,
|
|
|
|
|
Tags: []string{EnginePostgres, EngineElasticSearch},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should search across teams",
|
|
|
|
|
Fn: testSearchAcrossTeams,
|
|
|
|
|
Tags: []string{EngineAll},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSearchPostStore(t *testing.T, s store.Store, testEngine *SearchTestEngine) {
|
|
|
|
|
@@ -289,7 +294,7 @@ func testSearchPostsIncludingDMs(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -311,13 +316,13 @@ func testSearchPostsWithPagination(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -332,7 +337,7 @@ func testSearchReturnPinnedAndUnpinned(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -353,7 +358,7 @@ func testSearchExactPhraseInQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "\"channel test 1 2 3\""}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -369,7 +374,7 @@ func testSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search email addresses enclosed by quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"test@test.com\""}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -378,7 +383,7 @@ func testSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search email addresses without quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "test@test.com"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -393,7 +398,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search the start inside the markdown underscore", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "start"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -402,7 +407,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search a word in the middle of the markdown underscore", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "middle"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -411,7 +416,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search in the end of the markdown underscore", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "end"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -420,7 +425,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search inside markdown underscore", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "another"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -438,7 +443,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -446,7 +451,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你好"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -454,7 +459,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -469,7 +474,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "слово"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -477,7 +482,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search using wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "слов*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -494,7 +499,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -503,7 +508,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本木"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -511,7 +516,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -529,7 +534,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -537,7 +542,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불다"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -545,7 +550,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -563,7 +568,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "Straße"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -571,7 +576,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "Strasse"}
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -587,7 +592,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "café"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -595,7 +600,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "café"}
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -603,7 +608,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "cafe"}
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -621,7 +626,7 @@ func testSearchOrExcludePostsBySpecificUser(t *testing.T, th *SearchTestHelper)
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
FromUsers: []string{th.User.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -640,7 +645,7 @@ func testSearchOrExcludePostsInChannel(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{th.ChannelBasic.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -668,7 +673,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{direct.Id, group.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -681,7 +686,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{direct.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -693,7 +698,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{group.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -718,7 +723,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
OnDate: "2020-03-22",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -729,7 +734,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedDate: "2020-03-22",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -755,7 +760,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
BeforeDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -768,7 +773,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedBeforeDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -793,7 +798,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
AfterDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -805,7 +810,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedAfterDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -828,7 +833,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one",
|
|
|
|
|
ExcludedTerms: "five eight",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -840,7 +845,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one",
|
|
|
|
|
ExcludedTerms: "\"eight nine\"",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -863,7 +868,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one two",
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -876,7 +881,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one two",
|
|
|
|
|
OrTerms: false,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -903,7 +908,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
FromUsers: []string{th.User2.Id},
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -916,7 +921,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
ExcludedUsers: []string{th.User2.Id},
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -930,7 +935,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
ExcludedAfterDate: "2020-03-11",
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -942,7 +947,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
AfterDate: "2020-03-11",
|
|
|
|
|
ExcludedChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -965,7 +970,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "the search",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -976,7 +981,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "a avoid",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -987,7 +992,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "in where you",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1020,7 +1025,7 @@ func testSupportStemming(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "search",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1041,7 +1046,7 @@ func testSupportWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "search*",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1053,7 +1058,7 @@ func testSupportWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "sear* post",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1073,7 +1078,7 @@ func testNotSupportPrecedingWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "*earch",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -1089,7 +1094,7 @@ func testSearchDiscardWildcardAlone(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "qwerty *",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1107,7 +1112,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "term-with-dash",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1118,7 +1123,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "\"term-with-dash\"",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1137,7 +1142,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "term_with_underscore",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1148,7 +1153,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "\"term_with_underscore\"",
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1170,7 +1175,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1183,7 +1188,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: false,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1209,7 +1214,7 @@ func testSearchHashtagWithMarkdown(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 5)
|
|
|
|
|
@@ -1232,7 +1237,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashone #hashtwo",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1245,7 +1250,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1263,7 +1268,7 @@ func testSearchPostsWithDotsInHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag.dot",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1284,7 +1289,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1298,7 +1303,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#HASHTAG",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1312,7 +1317,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#HaShTaG",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1333,7 +1338,7 @@ func testSearchHashtagWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag-test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1351,7 +1356,7 @@ func testSearchHashtagWithNumbers(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#h4sht4g",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1369,7 +1374,7 @@ func testSearchHashtagWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag.test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1387,7 +1392,7 @@ func testSearchHashtagWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag_test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1410,7 +1415,7 @@ func testSearchShouldExcludeSytemMessages(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test system"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -1426,7 +1431,7 @@ func testSearchShouldBeAbleToMatchByMentions(t *testing.T, th *SearchTestHelper)
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "@testuser"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1446,7 +1451,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Doesn't include posts in deleted channels", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: false}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1456,7 +1461,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Include posts in deleted channels", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1467,7 +1472,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Include posts in deleted channels using multiple terms", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message channel", IncludeDeletedChannels: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1482,7 +1487,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
IncludeDeletedChannels: true,
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1500,7 +1505,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IncludeDeletedChannels: false,
|
|
|
|
|
}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, results)
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
})
|
|
|
|
|
@@ -1515,7 +1520,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with dash", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with-dash-term"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1524,7 +1529,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with quoted dash", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"with-dash-term\""}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1533,7 +1538,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple terms with one having dash", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with-dash-term message"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1542,7 +1547,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple OR terms with one having dash", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with-dash-term message", OrTerms: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1560,7 +1565,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with dots", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with.dots.term"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1569,7 +1574,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with quoted dots", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"with.dots.term\""}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1578,7 +1583,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple terms with one having dots", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with.dots.term message"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1587,7 +1592,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple OR terms with one having dots", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with.dots.term message", OrTerms: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1605,7 +1610,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with underscores", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with_underscores_term"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1614,7 +1619,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with quoted underscores", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"with_underscores_term\""}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1623,7 +1628,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple terms with one having underscores", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with_underscores_term message"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1632,7 +1637,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for multiple OR terms with one having underscores", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with_underscores_term message", OrTerms: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1654,7 +1659,7 @@ func testSearchBotAccountsPosts(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(bot.UserId)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "bot"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1673,7 +1678,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should stem appr", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "appr*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1684,7 +1689,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should stem approve", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "approve*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1701,7 +1706,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should return results without quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "hell*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1711,7 +1716,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should return just one result with quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"hell\"*"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1730,7 +1735,7 @@ func testHashtagSearchShouldSupportThreeOrMoreCharacters(t *testing.T, th *Searc
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "#123", IsHashtag: true}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1743,21 +1748,21 @@ func testSlashShouldNotBeCharSeparator(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "gamma"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p1.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "beta"}
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p1.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "alpha"}
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1772,7 +1777,7 @@ func testSearchEmailsWithoutQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test@test.com"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1787,7 +1792,7 @@ func testSupportSearchInComments(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "reply"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1800,7 +1805,7 @@ func testSupportSearchTermsWithinLinks(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "wikipedia"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1813,8 +1818,26 @@ func testShouldNotReturnLinksEmbeddedInMarkdown(t *testing.T, th *SearchTestHelp
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "wikipedia"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testSearchAcrossTeams(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
err := th.addUserToChannels(th.User, []string{th.ChannelAnotherTeam.Id})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
defer th.Store.Channel().RemoveMember(th.ChannelAnotherTeam.Id, th.User.Id)
|
|
|
|
|
|
|
|
|
|
_, err = th.createPost(th.User.Id, th.ChannelAnotherTeam.Id, "text to search", "", model.PostTypeDefault, 0, false)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
_, err = th.createPost(th.User.Id, th.ChannelBasic.Id, "text to search", "", model.PostTypeDefault, 0, false)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "search"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsForUser([]*model.SearchParams{params}, th.User.Id, "", 0, 20)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
}
|
|
|
|
|
|