MM-29067 Add deterministic IDs for default sidebar categories (#16030)

Automatic Merge
Этот коммит содержится в:
Harrison Healey
2020-10-29 10:24:01 -04:00
коммит произвёл GitHub
родитель 28983fa88d
Коммит 8bb772638c
8 изменённых файлов: 113 добавлений и 10 удалений

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

@@ -6,6 +6,7 @@ package storetest
import (
"database/sql"
"errors"
"sync"
"testing"
"github.com/mattermost/mattermost-server/v5/model"
@@ -99,6 +100,29 @@ func testCreateInitialSidebarCategories(t *testing.T, ss store.Store) {
assert.Equal(t, initialCategories.Categories, res.Categories)
})
t.Run("shouldn't create additional categories when ones already exist even when ran simultaneously", func(t *testing.T) {
userId := model.NewId()
teamId := model.NewId()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
_ = ss.Channel().CreateInitialSidebarCategories(userId, teamId)
}()
}
wg.Wait()
res, err := ss.Channel().GetSidebarCategories(userId, teamId)
assert.Nil(t, err)
assert.Len(t, res.Categories, 3)
})
t.Run("should populate the Favorites category with regular channels", func(t *testing.T) {
userId := model.NewId()
teamId := model.NewId()