package repository

import (
	"baron-sso-backend/internal/domain"
	"context"
	"testing"

	"github.com/lib/pq"
	"github.com/stretchr/testify/assert"
)

func TestClientConsentRepository_Find_IgnoresSoftDeletedConsent(t *testing.T) {
	repo := NewClientConsentRepository(testDB)
	ctx := context.Background()

	consent := &domain.ClientConsent{
		ClientID:      "client-soft-delete",
		Subject:       "user-soft-delete",
		GrantedScopes: pq.StringArray{"openid", "profile"},
	}

	err := repo.Upsert(ctx, consent)
	assert.NoError(t, err)

	err = repo.Delete(ctx, consent.Subject, consent.ClientID)
	assert.NoError(t, err)

	found, err := repo.Find(ctx, consent.ClientID, consent.Subject)
	assert.NoError(t, err)
	assert.Nil(t, found)
}
