// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef

// E2e tests for category: pdf
package e2e_test

import (
	"os"
	"testing"

	"github.com/stretchr/testify/assert"

	kreuzberg "github.com/kreuzberg-dev/kreuzberg/v5"
)

func Test_RenderPdfPageFirst(t *testing.T) {
	// render_pdf_page_to_png: first page
	pdf_bytesBytes, pdf_bytesBytesErr := os.ReadFile(`pdf/fake_memo.pdf`)
	if pdf_bytesBytesErr != nil {
		t.Fatalf("read fixture pdf/fake_memo.pdf: %v", pdf_bytesBytesErr)
	}
	result, err := kreuzberg.RenderPdfPageToPng(pdf_bytesBytes, 0, nil, nil)
	if err != nil {
		t.Fatalf("call failed: %v", err)
	}
	value := result
	assert.GreaterOrEqual(t, len(value), 100, "expected length >= 100")
}

func Test_RenderPdfPageOutOfRange(t *testing.T) {
	// render_pdf_page_to_png: page out of range
	pdf_bytesBytes, pdf_bytesBytesErr := os.ReadFile(`pdf/fake_memo.pdf`)
	if pdf_bytesBytesErr != nil {
		t.Fatalf("read fixture pdf/fake_memo.pdf: %v", pdf_bytesBytesErr)
	}
	_, err := kreuzberg.RenderPdfPageToPng(pdf_bytesBytes, 999, nil, nil)
	if err == nil {
		t.Errorf("expected an error, but call succeeded")
	}
}
