-
Notifications
You must be signed in to change notification settings - Fork 288
Set a date format on a date column for update test. #380
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
Set a date format on a date column for update test. #380
Conversation
@matt-h does the generated test fail previously? |
Yes, the test generated from this draft before this change fails. The failures is:
|
I'm still thinking on this. I understand it is a bug. But I'm trying to think of the convention I want to use for these cases. Said another way, what communicates the best in the test. Simply formatting the returned date implicitly makes the comparison work for Faker. So I'm wondering if explicitly casting the faker object to Carbon and relying upon its equality check would be better. |
I think I like setting the Faker item to Carbon here. Makes it clear that you are getting a Carbon object back from the Model and checks that the actual Carbon object matches (has no time set). |
Fair. Then the generated code for the request would need to be formatted. |
date. Otherwise you get an error that the date string doesn't match a Carbon object.
I just pushed an update to this that uses |
I do think I like this better. However, looks like we have some failing tests. |
Looking at the test details, looks like Github Actions just failed to start for some of them.
And
Are you able to just have it retry the tests? |
Looks like the re-run fixed it. |
When using a
date
field without time the tests need to check against a formatted date.Otherwise when running the tests you get an error that the date string does not match a Carbon object.
I'm using this basic
draft.yaml
This update checks if the field type is a
date
during the test generator and includes a format. This was the simplest way I could find to check if the column was adate
. If there was more than 1 exception, I could see refactoring this out to a Registry like for Faker.I tested this against both Laravel 7 and 8