Files
yellowjacket/backend/favorites/config_test.go
T
yonlu f9b2ad95b7 test(04-02): add config and sub-config validation tests
- Theme: hex color regex + background shade enum validation
- Tracklist: column ID recognition + duplicate detection
- Favorites: icon style enum validation
- Library: directory existence + scan concurrency mode validation
- Config: load/save roundtrip, missing file handling, composed errors, defaults
2026-03-03 17:00:12 -05:00

50 lines
920 B
Go

package favorites
import (
"testing"
)
func TestFavoritesConfig_Validate_ValidIconStyles(t *testing.T) {
t.Parallel()
tests := []struct {
name string
style IconStyle
}{
{"heart", IconHeart},
{"star", IconStar},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
c := &Config{IconStyle: tt.style}
if err := c.Validate(); err != nil {
t.Errorf("Validate() returned unexpected error: %v", err)
}
})
}
}
func TestFavoritesConfig_Validate_InvalidIconStyle(t *testing.T) {
t.Parallel()
c := &Config{IconStyle: "diamond"}
err := c.Validate()
if err == nil {
t.Fatal("Validate() expected error for unknown icon style, got nil")
}
}
func TestFavoritesConfig_ApplyDefaults(t *testing.T) {
t.Parallel()
c := &Config{}
c.ApplyDefaults()
if c.IconStyle != DefaultIconStyle {
t.Errorf("IconStyle = %q, want %q", c.IconStyle, DefaultIconStyle)
}
}