mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
refactor: Trim spaces from name and color in custom profile attribute select option constructor
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
|
||||
package model
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const CustomProfileAttributesPropertyGroupName = "custom_profile_attributes"
|
||||
|
||||
@@ -35,8 +38,8 @@ type CustomProfileAttributesSelectOption struct {
|
||||
func NewCustomProfileAttributeSelectOption(name, color string) CustomProfileAttributesSelectOption {
|
||||
return CustomProfileAttributesSelectOption{
|
||||
ID: NewId(),
|
||||
Name: name,
|
||||
Color: color,
|
||||
Name: strings.TrimSpace(name),
|
||||
Color: strings.TrimSpace(color),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,13 @@ func TestNewCustomProfileAttributeSelectOption(t *testing.T) {
|
||||
assert.Equal(t, "Test Option", option.Name)
|
||||
assert.Equal(t, "#FF0000", option.Color)
|
||||
})
|
||||
|
||||
t.Run("trims spaces from name and color", func(t *testing.T) {
|
||||
option := NewCustomProfileAttributeSelectOption(" Test Option ", " #FF0000 ")
|
||||
|
||||
assert.Equal(t, "Test Option", option.Name)
|
||||
assert.Equal(t, "#FF0000", option.Color)
|
||||
})
|
||||
}
|
||||
|
||||
func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user