mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
re-arrange the tests to run only on DB
```release-note NONE ```
This commit is contained in:
parent
33e284dae7
commit
a58dcb0c42
@ -35,6 +35,11 @@ var searchPostStoreTests = []searchTest{
|
|||||||
Fn: testSearchANDORQuotesCombinations,
|
Fn: testSearchANDORQuotesCombinations,
|
||||||
Tags: []string{EnginePostgres, EngineMySQL, EngineElasticSearch},
|
Tags: []string{EnginePostgres, EngineMySQL, EngineElasticSearch},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "Should be able to search without stemming",
|
||||||
|
Fn: testStemming,
|
||||||
|
Tags: []string{EnginePostgres, EngineMySQL},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Postgres supports search with and without quotes
|
// Postgres supports search with and without quotes
|
||||||
Name: "Should be able to search for email addresses with or without quotes",
|
Name: "Should be able to search for email addresses with or without quotes",
|
||||||
@ -366,10 +371,6 @@ func testSearchANDORQuotesCombinations(t *testing.T, th *SearchTestHelper) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
p3, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "one five six", "", model.PostTypeDefault, 0, false)
|
p3, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "one five six", "", model.PostTypeDefault, 0, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
p4, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "great minds think", "", model.PostTypeDefault, 0, false)
|
|
||||||
require.NoError(t, err)
|
|
||||||
p5, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "mindful of what you think", "", model.PostTypeDefault, 0, false)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
defer th.deleteUserPosts(th.User.Id)
|
defer th.deleteUserPosts(th.User.Id)
|
||||||
|
|
||||||
@ -450,26 +451,57 @@ func testSearchANDORQuotesCombinations(t *testing.T, th *SearchTestHelper) {
|
|||||||
expectedLen: 2,
|
expectedLen: 2,
|
||||||
expectedIDs: []string{p1.Id, p2.Id},
|
expectedIDs: []string{p1.Id, p2.Id},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
params := &model.SearchParams{Terms: tc.terms, OrTerms: tc.orTerms}
|
||||||
|
results, err := th.Store.Post().SearchPostsForUser(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Len(t, results.Posts, tc.expectedLen)
|
||||||
|
for _, id := range tc.expectedIDs {
|
||||||
|
th.checkPostInSearchResults(t, id, results.Posts)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testStemming(t *testing.T, th *SearchTestHelper) {
|
||||||
|
p1, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "great minds think", "", model.PostTypeDefault, 0, false)
|
||||||
|
require.NoError(t, err)
|
||||||
|
p2, err := th.createPost(th.User.Id, th.ChannelBasic.Id, "mindful of what you think", "", model.PostTypeDefault, 0, false)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
defer th.deleteUserPosts(th.User.Id)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
terms string
|
||||||
|
orTerms bool
|
||||||
|
expectedLen int
|
||||||
|
expectedIDs []string
|
||||||
|
}{
|
||||||
{
|
{
|
||||||
name: "simple search, no stemming",
|
name: "simple search, no stemming",
|
||||||
terms: `"minds think"`,
|
terms: `"minds think"`,
|
||||||
orTerms: false,
|
orTerms: false,
|
||||||
expectedLen: 1,
|
expectedLen: 1,
|
||||||
expectedIDs: []string{p4.Id},
|
expectedIDs: []string{p1.Id},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "simple search, single word, no stemming",
|
name: "simple search, single word, no stemming",
|
||||||
terms: `"minds"`,
|
terms: `"minds"`,
|
||||||
orTerms: false,
|
orTerms: false,
|
||||||
expectedLen: 1,
|
expectedLen: 1,
|
||||||
expectedIDs: []string{p4.Id},
|
expectedIDs: []string{p1.Id},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "non-simple search, stemming",
|
name: "non-simple search, stemming",
|
||||||
terms: `minds think`,
|
terms: `minds think`,
|
||||||
orTerms: true,
|
orTerms: true,
|
||||||
expectedLen: 2,
|
expectedLen: 2,
|
||||||
expectedIDs: []string{p4.Id, p5.Id},
|
expectedIDs: []string{p1.Id, p2.Id},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "simple search, no stemming, no results",
|
name: "simple search, no stemming, no results",
|
||||||
|
Loading…
Reference in New Issue
Block a user