MM-47465: Fix flaky TestDeleteChannel (#21686)

Creating the post in a separate goroutine would create a race condition
because that method also calls GetChannel. This can cause a bug
if the cache was wiped before the the other goroutine would get
a chance to update the cache. And if that happens, then
it would populate the cache with the old value.

Pseudo-code

```
func deleteChannel() {
    go func() {
        getFromCache()
    }()
    updateDB()
    wipeCache() // a
}

func getFromCache() {
    err := checkCache()
    if err == ErrNotFound {
        getFromDB() // x
        updateCache() // y
    }
}

func Test() {
    deleteChannel()
    getFromCache()
}
```

If the sequence of events happen like
- x
- a
- y

Then the getFromCache() call later will get the wrong
value from cache.

The fix is to make the call synchronous.

https://mattermost.atlassian.net/browse/MM-47465

Special thanks to @noxer for finding the root cause.

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-11-17 20:44:18 +05:30
коммит произвёл GitHub
родитель 5be8557247
Коммит 06ad69a406
2 изменённых файлов: 6 добавлений и 10 удалений

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

@@ -1779,7 +1779,6 @@ func TestSearchGroupChannels(t *testing.T) {
}
func TestDeleteChannel(t *testing.T) {
t.Skip("MM-47465")
th := Setup(t).InitBasic()
defer th.TearDown()
c := th.Client