package builder

import "testing"

func TestNormalizeRegistryPersistenceSingleCheckbox(t *testing.T) {
	req := &BuildRequest{RegistryRunOnce: true}
	normalizeRegistryPersistence(req)
	if req.RegistryPersistence != "hkcu_run_once" {
		t.Fatalf("got %q", req.RegistryPersistence)
	}
}

func TestNormalizeRegistryPersistenceCombined(t *testing.T) {
	req := &BuildRequest{RegistryRunHKCU: true, RegistryRunOnce: true}
	normalizeRegistryPersistence(req)
	if req.RegistryPersistence != "combined" {
		t.Fatalf("got %q", req.RegistryPersistence)
	}
}

func TestNormalizeRegistryPersistenceEnumWins(t *testing.T) {
	req := &BuildRequest{
		RegistryPersistence: "hkcu_run",
		RegistryRunHKLM:     true,
	}
	normalizeRegistryPersistence(req)
	if req.RegistryPersistence != "hkcu_run" {
		t.Fatalf("enum should win, got %q", req.RegistryPersistence)
	}
}
