mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
refactor: Make color field optional in custom profile attributes
This commit is contained in:
@@ -111,10 +111,6 @@ func (c CustomProfileAttributesSelectOption) IsValid() error {
|
||||
return errors.New("name cannot be empty")
|
||||
}
|
||||
|
||||
if c.Color == "" {
|
||||
return errors.New("color cannot be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) {
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "valid option",
|
||||
name: "valid option with color",
|
||||
option: CustomProfileAttributesSelectOption{
|
||||
ID: NewId(),
|
||||
Name: "Test Option",
|
||||
@@ -60,6 +60,14 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) {
|
||||
},
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
name: "valid option without color",
|
||||
option: CustomProfileAttributesSelectOption{
|
||||
ID: NewId(),
|
||||
Name: "Test Option",
|
||||
},
|
||||
wantErr: "",
|
||||
},
|
||||
{
|
||||
name: "empty ID",
|
||||
option: CustomProfileAttributesSelectOption{
|
||||
@@ -87,15 +95,6 @@ func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) {
|
||||
},
|
||||
wantErr: "name cannot be empty",
|
||||
},
|
||||
{
|
||||
name: "empty color",
|
||||
option: CustomProfileAttributesSelectOption{
|
||||
ID: NewId(),
|
||||
Name: "Test Option",
|
||||
Color: "",
|
||||
},
|
||||
wantErr: "color cannot be empty",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -200,7 +199,7 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) {
|
||||
wantErr: "options list cannot be empty",
|
||||
},
|
||||
{
|
||||
name: "valid options",
|
||||
name: "valid options with and without color",
|
||||
options: CustomProfileAttributesSelectOptions{
|
||||
{
|
||||
ID: NewId(),
|
||||
@@ -210,7 +209,6 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) {
|
||||
{
|
||||
ID: NewId(),
|
||||
Name: "Option 2",
|
||||
Color: "#00FF00",
|
||||
},
|
||||
},
|
||||
wantErr: "",
|
||||
@@ -226,7 +224,6 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) {
|
||||
{
|
||||
ID: "",
|
||||
Name: "Option 2",
|
||||
Color: "#00FF00",
|
||||
},
|
||||
},
|
||||
wantErr: "invalid option at index 1: id cannot be empty",
|
||||
|
||||
Reference in New Issue
Block a user