[MM-36472] Fix inconsistencies in Roles columns (#18390)
* Fix inconsistencies in Roles columns * Add new migrations
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
305e4793c3
Коммит
177680f08c
@@ -5,12 +5,74 @@ package model
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSessionIsValid(t *testing.T) {
|
||||
tcs := []struct {
|
||||
name string
|
||||
input Session
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
"Invalid Id",
|
||||
Session{},
|
||||
"model.session.is_valid.id.app_error",
|
||||
},
|
||||
{
|
||||
"Invalid UserId",
|
||||
Session{
|
||||
Id: NewId(),
|
||||
},
|
||||
"model.session.is_valid.user_id.app_error",
|
||||
},
|
||||
{
|
||||
"Invalid CreateAt",
|
||||
Session{
|
||||
Id: NewId(),
|
||||
UserId: NewId(),
|
||||
},
|
||||
"model.session.is_valid.create_at.app_error",
|
||||
},
|
||||
{
|
||||
"Invalid Roles",
|
||||
Session{
|
||||
Id: NewId(),
|
||||
UserId: NewId(),
|
||||
CreateAt: 1000,
|
||||
Roles: strings.Repeat("a", UserRolesMaxLength+1),
|
||||
},
|
||||
"model.session.is_valid.roles_limit.app_error",
|
||||
},
|
||||
{
|
||||
"Valid",
|
||||
Session{
|
||||
Id: NewId(),
|
||||
UserId: NewId(),
|
||||
CreateAt: 1000,
|
||||
Roles: strings.Repeat("a", UserRolesMaxLength),
|
||||
},
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := tc.input.IsValid()
|
||||
if tc.expectedError != "" {
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, tc.expectedError, err.Id)
|
||||
} else {
|
||||
require.Nil(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionDeepCopy(t *testing.T) {
|
||||
sessionId := NewId()
|
||||
userId := NewId()
|
||||
|
||||
Ссылка в новой задаче
Block a user