mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-13 21:28:02 -05:00
📝 Add docstrings to limit-pages-ocr
Docstrings generation was requested by @icereed. * https://github.com/icereed/paperless-gpt/pull/102#issuecomment-2582999315 The following files were modified: * `main.go` * `paperless_test.go`
This commit is contained in:
parent
ebc26b5bdf
commit
ea97e3b660
2 changed files with 5 additions and 2 deletions
2
main.go
2
main.go
|
@ -262,7 +262,7 @@ func isOcrEnabled() bool {
|
||||||
return visionLlmModel != "" && visionLlmProvider != ""
|
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() {
|
func validateOrDefaultEnvVars() {
|
||||||
if manualTag == "" {
|
if manualTag == "" {
|
||||||
manualTag = "paperless-gpt"
|
manualTag = "paperless-gpt"
|
||||||
|
|
|
@ -363,7 +363,7 @@ func TestUrlEncode(t *testing.T) {
|
||||||
assert.Equal(t, expected, result)
|
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) {
|
func TestDownloadDocumentAsImages(t *testing.T) {
|
||||||
env := newTestEnv(t)
|
env := newTestEnv(t)
|
||||||
defer env.teardown()
|
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) {
|
func TestDownloadDocumentAsImages_ManyPages(t *testing.T) {
|
||||||
env := newTestEnv(t)
|
env := newTestEnv(t)
|
||||||
defer env.teardown()
|
defer env.teardown()
|
||||||
|
|
Loading…
Reference in a new issue