package handlers

import (
	"testing"

	"github.com/breakpilot/ai-compliance-sdk/internal/iace"
)

func TestResolvePresence(t *testing.T) {
	none := componentReviewDecision{}
	tests := []struct {
		name     string
		dec      componentReviewDecision
		has      bool
		negated  bool
		want     string
	}{
		{"no decision, present", none, false, false, iace.PresencePresent},
		{"no decision, negated", none, false, true, iace.PresenceAbsent},
		{"expert un-negated wins", componentReviewDecision{presence: iace.PresencePresent}, true, true, iace.PresencePresent},
		{"expert negated wins", componentReviewDecision{presence: iace.PresenceAbsent}, true, false, iace.PresenceAbsent},
		{"expert deleted persists", componentReviewDecision{presence: iace.PresenceDeleted}, true, false, iace.PresenceDeleted},
		{"empty decision falls back to engine", componentReviewDecision{presence: ""}, true, true, iace.PresenceAbsent},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := resolvePresence(tt.dec, tt.has, tt.negated); got != tt.want {
				t.Errorf("got %q, want %q", got, tt.want)
			}
		})
	}
}
