Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock PDFGenerator for testing #29

Merged
merged 3 commits into from
Jul 27, 2022
Merged

Mock PDFGenerator for testing #29

merged 3 commits into from
Jul 27, 2022

Conversation

tagatac
Copy link
Owner

@tagatac tagatac commented Jul 27, 2022

Closes #26
Also renders #18 invalid as we are now only concerned with the inputs to wkhtmltopdf, and not its behavior.

@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #29 (81e3367) into main (86f9b32) will increase coverage by 1.13%.
The diff coverage is 94.00%.

@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
+ Coverage   96.65%   97.79%   +1.13%     
==========================================
  Files           7        6       -1     
  Lines         748      724      -24     
==========================================
- Hits          723      708      -15     
+ Misses         17       11       -6     
+ Partials        8        5       -3     
Impacted Files Coverage Δ
opsys/opsys.go 95.83% <ø> (ø)
write.go 97.76% <88.00%> (-2.24%) ⬇️
opsys/outfile.go 100.00% <100.00%> (+9.09%) ⬆️
opsys/pdfgen/pdfgen.go

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86f9b32...81e3367. Read the comment docs.

@tagatac tagatac merged commit 6d7d7fd into main Jul 27, 2022
@tagatac tagatac deleted the mock-pdfgen branch July 27, 2022 10:18
tagatac added a commit that referenced this pull request Sep 10, 2024
**What is changing**: Check the OS-level open file limit (and adjust it
if necessary) prior to writing PDF files.

**Why this change is being made**: There is the potential for
wkhtmltopdf to need many open files (see
wkhtmltopdf/wkhtmltopdf#3081). This was fixed
in #14, where it depended on the order of events:
1. Stage the PDF file, getting the number of images
2. Check and adjust the open file limit
3. Flush the PDF file to disk

Number 3 was achieved via the call `defer outFile.Close()`:
https://github.com/tagatac/bagoup/blob/86f9b32870d2127f3fd3e196cecfc24265cf8d87/write.go#L29

However, #29 removed `Close()` from the `OutFile` interface, collapsing
`Stage()` and `Flush()` into a single function `Flush()` run prior to
checking and adjusting the open file limit.

**Related issue(s)**: Fixes #63 

**Follow-up changes needed**: None AFAIK

**Is the change completely covered by unit tests? If not, why not?**:
Yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inject a PDFGenerator into OS.NewOutFile
1 participant