MM-29479: Fix racy test TestSidebarCategory (#16255)

Automatic Merge
Этот коммит содержится в:
Agniva De Sarker
2020-11-11 23:19:56 +05:30
коммит произвёл GitHub
родитель 3782b3e21b
Коммит 87a5510adc

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

@@ -62,8 +62,12 @@ func TestSidebarCategory(t *testing.T) {
err = th.App.UpdateSidebarCategoryOrder(user.Id, th.BasicTeam.Id, actualOrder)
require.Nil(t, err, "Should update order successfully")
actualOrder[2] = "asd"
err = th.App.UpdateSidebarCategoryOrder(user.Id, th.BasicTeam.Id, actualOrder)
// We create a copy of actualOrder to prevent racy read
// of the slice when the broadcast message is sent from webhub.
newOrder := make([]string, len(actualOrder))
copy(newOrder, actualOrder)
newOrder[2] = "asd"
err = th.App.UpdateSidebarCategoryOrder(user.Id, th.BasicTeam.Id, newOrder)
require.NotNil(t, err, "Should return error due to invalid id")
})