MM-43871: Fix flaky TestCreatePostAsUser (#20484)

We need to flush the logger before checking
the log results. Without that, sometimes
it would get logged after checking the line,
as can be seen in the JIRA ticket.

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

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2022-06-16 14:17:01 +05:30
коммит произвёл GitHub
родитель c7aa2fdbb5
Коммит f15873eaf4

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

@@ -1108,7 +1108,6 @@ func TestCreatePostAsUser(t *testing.T) {
})
t.Run("logs warning for user not in channel", func(t *testing.T) {
t.Skip("MM-43871")
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.CreateUser()
@@ -1123,6 +1122,8 @@ func TestCreatePostAsUser(t *testing.T) {
_, appErr := th.App.CreatePostAsUser(th.Context, post, "", true)
require.Nil(t, appErr)
require.NoError(t, th.TestLogger.Flush())
testlib.AssertLog(t, th.LogBuffer, mlog.LvlWarn.Name, "Failed to get membership")
})
@@ -1146,6 +1147,8 @@ func TestCreatePostAsUser(t *testing.T) {
_, appErr = th.App.CreatePostAsUser(th.Context, post, "", true)
require.Nil(t, appErr)
require.NoError(t, th.TestLogger.Flush())
testlib.AssertNoLog(t, th.LogBuffer, mlog.LvlWarn.Name, "Failed to get membership")
})