diff --git a/main.go b/main.go index 783fa7e..a29bd98 100644 --- a/main.go +++ b/main.go @@ -262,7 +262,7 @@ func isOcrEnabled() bool { return visionLlmModel != "" && visionLlmProvider != "" } -// validateOrDefaultEnvVars ensures all necessary environment variables are set +// validateOrDefaultEnvVars validates and sets default values for environment variables required by the application. It ensures that necessary configuration parameters are present and sets sensible defaults where possible. The function checks and configures tags for manual and automatic document processing, validates Paperless URL and API token, verifies LLM provider and model settings, and handles OCR page limit configuration. If any critical environment variables are missing, the function will terminate the application with a fatal error. func validateOrDefaultEnvVars() { if manualTag == "" { manualTag = "paperless-gpt" diff --git a/paperless_test.go b/paperless_test.go index 85e056a..f8a830a 100644 --- a/paperless_test.go +++ b/paperless_test.go @@ -363,7 +363,7 @@ func TestUrlEncode(t *testing.T) { assert.Equal(t, expected, result) } -// TestDownloadDocumentAsImages tests the DownloadDocumentAsImages method +// 4. The image file is successfully created on the filesystem func TestDownloadDocumentAsImages(t *testing.T) { env := newTestEnv(t) defer env.teardown() @@ -398,6 +398,9 @@ func TestDownloadDocumentAsImages(t *testing.T) { } } +// TestDownloadDocumentAsImages_ManyPages tests the DownloadDocumentAsImages method for a multi-page PDF document with a specified page limit. +// It verifies that the method correctly extracts a limited number of pages from a PDF, generates image files, and returns the correct image paths. +// The test ensures that exactly 50 pages are extracted from a 52-page document and that the image files are created in the expected location. func TestDownloadDocumentAsImages_ManyPages(t *testing.T) { env := newTestEnv(t) defer env.teardown()