Refactor: func StringInSlice to slices.Contains (#24262)

* Refactor: Use generic to change func StringInSlice to Contains

* Refactor: Use generic to change func stringNotInSlice to Contains

Make utils.go (dir server/public/utils) and func Contains

* Refactor: Move func Contains from channels/utils to public/utils

Move func Contains from channels/utils to public/utils

Fix import declarations line

* Docs: Add a description of the Contains function

* Test: add TestContains

Add a test code for a Contain function
Этот коммит содержится в:
Jian Lim
2023-09-01 16:05:27 +09:00
коммит произвёл GitHub
родитель 831a7db73d
Коммит 8c2fc88471
14 изменённых файлов: 443 добавлений и 46 удалений

Просмотреть файл

@@ -6,8 +6,9 @@ package searchtest
import (
"testing"
pUtils "github.com/mattermost/mattermost/server/public/utils"
"github.com/mattermost/mattermost/server/v8/channels/store"
"github.com/mattermost/mattermost/server/v8/channels/utils"
)
const (
@@ -35,12 +36,12 @@ type searchTest struct {
func filterTestsByTag(tests []searchTest, tags ...string) []searchTest {
filteredTests := []searchTest{}
for _, test := range tests {
if utils.StringInSlice(EngineAll, test.Tags) {
if pUtils.Contains(test.Tags, EngineAll) {
filteredTests = append(filteredTests, test)
continue
}
for _, tag := range tags {
if utils.StringInSlice(tag, test.Tags) {
if pUtils.Contains(test.Tags, tag) {
filteredTests = append(filteredTests, test)
break
}