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
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user