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

Add tests for gobl to ksef conversion #3

Merged
merged 6 commits into from
Jan 15, 2024

Conversation

noplisu
Copy link
Collaborator

@noplisu noplisu commented Jan 12, 2024

Pull Request Summary

This PR adds some basic tests to the GOBL to KSeF conversion. We also do some cleanup in the test folder structure for it to mirror the implementation from gobl.cfdi. This changes allow us to move and adjust some test helper methods from gobl.cfdi for our tests.

For the tests to work we had to comment out some of the payments code. The issue with this code will be addressed in future PRs.

The last change is adding vscode settings to .gitignore since we don't want to have them in the repository

Feedback

There will be more tests added after this but I decided to create a PR with those 2 for a start. The next test will be a validation of the generated xml file against a xsd file, but the current draft of this test returns errors in our implementation that will need to be addressed with the test itself so I decided that it merits a PR for itself.

Since I am working using vscode and have some custom settings
for running tests, running and debugging go code I don't want
those settings to be commited to not pollute the repository
and not break any settings for other people.

To do that I add the .vscode folder to the .gitignore file.
Before we add tests we want to change the structure of the test
directory. This new strucutre is based on the structure we have in
glob.cfdi. This will allow us to use the same helper methods
in both projects.
To keep tests clean we add a test.go file into the test folder.
In this file we will keep helper functions that will help us
load example gobl data that we will be using in our tests.
This approach is mimicking the approach we have in gobl.cfdi.
In the test golb structure there is no payments data. Passing this
data into our KSeF parser results in an error. Since the payment data
is optional in KSeF we decided to comment out this part of the
code and address the issue after we add some tests to the existing code.
We are finally ready to add the first test to the golb KSeF
parser. Here we test the basic XML structure generated in the
ksef.go file.
As we want to be sure that the KSeF document is generated correctly
we add a test that checks if the generated KSeF xml is the same as
a KSeF xml in the out folder.
Copy link
Contributor

@samlown samlown left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@cavalle cavalle left a comment

Choose a reason for hiding this comment

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

Looks great!

@noplisu noplisu merged commit 10f35f0 into main Jan 15, 2024
2 checks passed
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.

3 participants