[10.x] Add serializeAndRestore()
to QueueFake
andBusFake
#48131
Merged
+187
−6
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.
Some context
Queues are awesome. Jobs are awesome. Faking within tests is awesome.
But testing that a job is pushed is not always enough. Nor is testing the job's properties match expected values.
The normal process for jobs is that they are pushed to the queue where they are serialized and deserialized when they are run by a worker process. If there is an issue trying to serialize an object for your queue, it will fail... but probably not within your test suite 😟
Take for instance this job:
If we write a unit test like:
We see no problem in our test suite so it gets approved and merged... but then we release it into production and all of these jobs fail to serialize.
Instead, now we can write our tests to leverage
QueueFake@serializeAndRestoreJobs()
. This simulates the queuing process insofar that we will callserialize()
andunserialize()
on the job.Will gladly add a PR(s) for this to be added to EventFake and BusFake.