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

Integration test coverage #329

Merged
merged 11 commits into from
Jan 28, 2019
Merged

Integration test coverage #329

merged 11 commits into from
Jan 28, 2019

Conversation

gunnsth
Copy link
Contributor

@gunnsth gunnsth commented Jan 23, 2019

Package e2etest implements integration tests with a small test corpus (externally provided). It currently has two tests:

  • Passthrough, which loads a PDF with unidoc, and writes back out and optionally validates with ghostscript ensuring that no errors are added by unidoc.
  • Allobjects which combs through all streams in the PDF and decodes, ensuring that there are no errors.

In the future we will add more integration test coverage and validation that the output is as expected. The current integration tests only ensure that there are no errors in loading, and outputing.

Added to Jenkinsfile to run in automatic builds and test coverage measurements. The test coverage is now obtained with

go test -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...

which measures the test coverage of all packages on all other packages within the projects, i.e. includes unit and integration tests.

Running the e2etests integration tests requires setting environment variables:

  • UNIDOC_GS_BIN_PATH should point to the executable binary for ghostscript
  • UNIDOC_E2E_FORCE_TESTS set to "1" if the tests are required to run
  • UNIDOC_PASSTHROUGH_TESTDATA should point to the folder containing test corpus files for passthrough test
  • UNIDOC_ALLOBJECTS_TESTDATA should point to the folder containing test corpus files for allobjects test.

@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #329 into v3 will increase coverage by 18.2%.
The diff coverage is 70%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v3     #329      +/-   ##
==========================================
+ Coverage   38.54%   56.75%   +18.2%     
==========================================
  Files         122      144      +22     
  Lines       23167    25098    +1931     
==========================================
+ Hits         8930    14244    +5314     
+ Misses      12956    10488    -2468     
+ Partials     1281      366     -915
Impacted Files Coverage Δ
pdf/internal/e2etest/validate.go 70% <70%> (ø)
pdf/contentstream/draw/bezier_curve.go 91.01% <0%> (ø)
pdf/core/security/crypt/filter_aesv2.go 31.81% <0%> (ø)
pdf/contentstream/draw/utils.go 100% <0%> (ø)
pdf/core/security/crypt/filters.go 45.45% <0%> (ø)
pdf/annotator/field_appearance.go 0% <0%> (ø)
pdf/annotator/line.go 0% <0%> (ø)
common/license/util.go 25% <0%> (ø)
pdf/internal/testutils/testutils.go 69.07% <0%> (ø)
... and 116 more

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 1dd3de8...18bacd0. Read the comment docs.

@gunnsth gunnsth added this to the v3.0.0-alpha.2 milestone Jan 23, 2019
@gunnsth gunnsth requested a review from adrg January 25, 2019 17:11
@gunnsth gunnsth added the priority High Priority label Jan 25, 2019
pdf/internal/e2etest/validate.go Outdated Show resolved Hide resolved
pdf/internal/e2etest/passthrough_test.go Outdated Show resolved Hide resolved
pdf/internal/e2etest/passthrough_test.go Outdated Show resolved Hide resolved
pdf/internal/e2etest/allobjects_test.go Show resolved Hide resolved
if err != nil {
return err
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line for consistency.

pdf/internal/e2etest/validate.go Outdated Show resolved Hide resolved
@adrg
Copy link
Collaborator

adrg commented Jan 27, 2019

The package does work as intended when setting all the environment variables. The code looks great to me. I've added a couple of minor changes and suggestions.

The only other suggestion would be to maybe add a function similar to the readPDF function in unicli (https://github.com/unidoc/unicli/blob/master/pdf/utils.go#L18) so that we don't repeat code when reading a PDF file (read, decrypt, get number of pages etc...). This is not really related to this PR because this function would be added in another package in unidoc but would improve the code here as well. Just something to take into consideration for the future.

@gunnsth
Copy link
Contributor Author

gunnsth commented Jan 28, 2019

@adrg I have addressed all review comments, please take another look.

@adrg
Copy link
Collaborator

adrg commented Jan 28, 2019

@gunnsth All the review points have been addressed. Tested again after pulling the new commits. Everything works as intended. 👍

@gunnsth gunnsth merged commit 2253e29 into v3 Jan 28, 2019
@gunnsth gunnsth deleted the v3-integration-testing branch January 28, 2019 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority High Priority
Projects
None yet
2 participants