package handler

import (
	"kra/internal/service/dto"
	"net/http/httptest"
	"testing"

	"github.com/gin-gonic/gin"
)

func TestWritePaymentCallbackAckDoesNotExposeError(t *testing.T) {
	gin.SetMode(gin.TestMode)
	recorder := httptest.NewRecorder()
	context, _ := gin.CreateTestContext(recorder)
	writePaymentCallbackAck(context, dto.PaymentCallbackAck{
		StatusCode:  500,
		ContentType: "text/plain; charset=utf-8",
		Body:        []byte("failure"),
	})
	if recorder.Code != 500 {
		t.Fatalf("status = %d, want 500", recorder.Code)
	}
	if recorder.Body.String() != "failure" {
		t.Fatalf("body = %q, want fixed failure ack", recorder.Body.String())
	}
	if recorder.Body.String() == "internal order resolver details" {
		t.Fatal("internal error was exposed in callback response")
	}
}
