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

test: add basic LDtk faker types and use them LevelMetadataAccessor tests #238

Merged
merged 12 commits into from
Oct 14, 2023

Conversation

Trouv
Copy link
Owner

@Trouv Trouv commented Oct 14, 2023

I would like to have more comprehensive tests, but one obstacle in that respect has always been that the LDtk json types were very difficult to construct for tests. They are quite complicated and massive, so writing custom test data is very time consuming and difficult to maintain. This seems to me like a good use case for a faker library, so that is what this PR implements.

You may notice that these faker types are not very sophisticated, and only edit a few fields. My thoughts are that, as tests need to fake more fields of these types, they are welcome to improve the fakers. The sorts of things that are faked here are those that are used in tests for the new asset types. These fakers are also pretty careful about making the faked data a little bit realistic.. in particular, all faked levels will have the "same" set of layers with some per-instance variation much like a real LDtk file. At the highest level, there are also fakers for creating an LdtkJson with unloaded levels, and a separate list of loaded levels, which can be added to an asset store for testing of accessing external level data in the future.

I wasn't too careful about documenting these new types for now, since they are all behind #[cfg(test)] and do not appear in the library. If contributors find these types confusing, it may be worth documenting them in a future PR.

@Trouv Trouv merged commit c950419 into main Oct 14, 2023
4 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.

1 participant