feat(theming): apply updates overlay theme_overrides.__active

This commit is contained in:
MDietermann
2026-04-14 13:11:34 +02:00
parent b422402ffc
commit 4fa580f226
2 changed files with 85 additions and 1 deletions

View File

@@ -79,3 +79,41 @@ func TestApplyUnknownThemeErrors(t *testing.T) {
t.Fatal("want error on unknown theme")
}
}
func TestApplyUpdatesOverlayActive(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
if err := Apply(config.Config{}, "gruvbox"); err != nil {
t.Fatal(err)
}
data, err := os.ReadFile(filepath.Join(home, ".config", "archduino", "overlay.yaml"))
if err != nil {
t.Fatalf("overlay missing: %v", err)
}
if !strings.Contains(string(data), "__active: gruvbox") {
t.Fatalf("overlay missing active theme: %s", data)
}
}
func TestApplyPreservesOtherOverlayKeys(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
op := filepath.Join(home, ".config", "archduino", "overlay.yaml")
if err := os.MkdirAll(filepath.Dir(op), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(op, []byte("version: 1\nextra_packages:\n - foo\n"), 0o644); err != nil {
t.Fatal(err)
}
if err := Apply(config.Config{}, "gruvbox"); err != nil {
t.Fatal(err)
}
data, _ := os.ReadFile(op)
if !strings.Contains(string(data), "- foo") {
t.Fatalf("extra_packages lost: %s", data)
}
if !strings.Contains(string(data), "__active: gruvbox") {
t.Fatalf("active theme missing after preserve: %s", data)
}
}