package gateway

import (
	"testing"

	"github.com/rose_cat707/luminary/internal/provider"
)

func TestExtractAPIErrorMessage_OpenAI(t *testing.T) {
	body := []byte(`{"error":{"message":"Invalid API key","type":"invalid_request_error"}}`)
	got := extractAPIErrorMessage(body)
	if got != "invalid_request_error: Invalid API key" {
		t.Fatalf("got %q", got)
	}
}

func TestDescribeForwardError_WithBody(t *testing.T) {
	got := describeForwardError(nil, &provider.ChatResponse{
		StatusCode: 400,
		Body:       []byte(`{"error":{"message":"model not found"}}`),
	})
	if got != "status 400: model not found" {
		t.Fatalf("got %q", got)
	}
}
