feat(factories): add factory craft command and location binding - #55
Open
Roshankc682 wants to merge 2 commits into
Open
feat(factories): add factory craft command and location binding#55Roshankc682 wants to merge 2 commits into
Roshankc682 wants to merge 2 commits into
Conversation
Scaffolds model factories via a new `factory` command and stub, wired into the existing masoniteorm.factories.Factory engine, following the same command/location pattern already used for jobs, seeds and mailables. Refs masonitedev#30
…ependency The generated factory hardcoded `app.models.<model>` as the import path, which only works when models.location is the skeleton default; it now derives the import from wherever models.location actually points, same as the rest of the framework's location-aware commands. Also request masonite-framework-orm's `seeder` extra so `faker` is installed, without which Factory.make()/create() always raised ImportError. Added an end-to-end test that generates a factory, imports it for real, and creates + queries a persisted record through it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
factorycraft command that scaffolds a model factory class from a stubmasoniteorm.factories.Factoryengine (register/make/create, faker integration — already shipped inmasonite-framework-orm)
factories.locationbinding (databases/factories), following the exact pattern already used forseeds.location/mailables.locationfactories_path()helper inutils/location.py, mirroringseeds_path()Refs
Partially addresses #30. This PR covers the command + stub + location-binding slice. Not yet covered (open to doing in a follow-up, or splitting further per
maintainer feedback):
name=param onFactory.register()masoniteorm.factories.Factoryat all; would need a change inmasonitedev/orm, a separate repoTest plan
tests/features/factories/test_make_factory_command.py(command creates factory,--modeloverride,--forceoverwrite protection),test_factories_pathintests/core/utils/test_location.pypytest tests -m "not integrations"— 700 passed, 22 failed (all pre-existing, environment-only: Windows path separators, missingPillow/ffmpeg — unrelated to this change)
Let me know once it's pushed and I'll double check the diff on GitHub before you submit, if you'd like.
Scaffolds model factories via a new
factorycommand and stub, wired into the existing masoniteorm.factories.Factory engine, following the same command/location pattern already used for jobs, seeds and mailables.Refs #30