Most of the test module utilities, like response_from_file_with_ext and assert_serialized are pub(crate). This prevents third-party crates from using these, e.g. when implementing extensions out of tree.
It would be helpful if third-party crates could use these.
They currently use private field access (e.g., RequestData::command), thus it requires a lot of duplicate code to be able to test extensions outside this crate.
Solutions consist of:
- making
response_from_file_with_ext and assert_serialized public here, or
- creating an instant-epp-test crate.
I suggest making them public inside of instant-epp as we would need to make lower level functions and fields public to be able to support an crate to implement these functions.
Functions that are useful for third-party crates are:
assert_serialized
response_from_file_with_ext
The test module also has response_from_file which does not support extensions and thus is not really useful for third-party crates.
get_xml is also not really useful.
One caveat lies in the way get_xml loads files. It currently uses ./tests/resources, which depends on the current working dir of the test execution. It is better than using CARGO_MANIFEST_PATH (due to that being set to instant-epp) but it would be worth a comment that external crates depend on the existing behavior (of using the current working dir) somewhere next to get_xml (or in docs for the two public functions) or the ability to pass on the path to assert_serialized and response_from_file_with_ext.
For the sake of keeping changes small, I suggest a comment. An alternative would be to add two new functions that are public and allow setting the complete path.
Happy to create a PR if you decide on the path forward.
Most of the test module utilities, like
response_from_file_with_extandassert_serializedarepub(crate). This prevents third-party crates from using these, e.g. when implementing extensions out of tree.It would be helpful if third-party crates could use these.
They currently use private field access (e.g.,
RequestData::command), thus it requires a lot of duplicate code to be able to test extensions outside this crate.Solutions consist of:
response_from_file_with_extandassert_serializedpublic here, orI suggest making them public inside of
instant-eppas we would need to make lower level functions and fields public to be able to support an crate to implement these functions.Functions that are useful for third-party crates are:
assert_serializedresponse_from_file_with_extThe test module also has
response_from_filewhich does not support extensions and thus is not really useful for third-party crates.get_xmlis also not really useful.One caveat lies in the way
get_xmlloads files. It currently uses./tests/resources, which depends on the current working dir of the test execution. It is better than usingCARGO_MANIFEST_PATH(due to that being set to instant-epp) but it would be worth a comment that external crates depend on the existing behavior (of using the current working dir) somewhere next toget_xml(or in docs for the two public functions) or the ability to pass on the path toassert_serializedandresponse_from_file_with_ext.For the sake of keeping changes small, I suggest a comment. An alternative would be to add two new functions that are public and allow setting the complete path.
Happy to create a PR if you decide on the path forward.