feat(theming): apply writes four tool configs to $HOME
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package theming
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/config"
|
||||
)
|
||||
|
||||
func TestListDiscoversThemes(t *testing.T) {
|
||||
@@ -40,3 +45,37 @@ func TestListIsSortedByID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyWritesFourToolConfigs(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
if err := Apply(config.Config{}, "gruvbox"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
checks := []struct{ rel, wantPrefix string }{
|
||||
{".config/starship.toml", "palette"},
|
||||
{".config/zellij/config.kdl", "theme"},
|
||||
{".config/yazi/theme.toml", ""},
|
||||
{".config/lazygit/config.yml", "gui"},
|
||||
}
|
||||
for _, c := range checks {
|
||||
data, err := os.ReadFile(filepath.Join(home, c.rel))
|
||||
if err != nil {
|
||||
t.Errorf("%s missing: %v", c.rel, err)
|
||||
continue
|
||||
}
|
||||
if len(data) == 0 {
|
||||
t.Errorf("%s empty", c.rel)
|
||||
}
|
||||
if c.wantPrefix != "" && !strings.HasPrefix(strings.TrimSpace(string(data)), c.wantPrefix) {
|
||||
t.Errorf("%s: want prefix %q, got %q", c.rel, c.wantPrefix, string(data[:min(len(data), 40)]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyUnknownThemeErrors(t *testing.T) {
|
||||
if err := Apply(config.Config{}, "does-not-exist"); err == nil {
|
||||
t.Fatal("want error on unknown theme")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user