refactor: Make color field optional in custom profile attributes

This commit is contained in:
Julien Tant (aider)
2025-02-12 17:06:22 -07:00
parent 7382b8ecb3
commit 2256076ed1
2 changed files with 10 additions and 17 deletions
@@ -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",