Add a simplified central object to act as porcelain for the mock #10
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.
This is a draft from the former location of
lava-api
; it's been parked for a long time, and may need some freshening up. There may be unaddressed feedback from previous iterations of this PR at present.The old MR description is below, and is likely in need of cleanup.
This contains essentially one reworked full-size test, in
lava-api/src/job.rs (test_basic), plus a much smaller, specific test
in test_basic_porcelain.
The porcelain object itself is another layer on top of the lava
mock. It incorporates a SimClock, which is often what you want for
reliable, sensible testing of time behaviour (where the time is
whatever you say it is).
The main inelegancies here:
The proxy interface is optional until it isn't: there's no
disguising that once you got hold of an object, it contains proxies.
There's very limited customisation, and it bridges poorly with other
ways of constructing more customised options. It effectively
functions as a simplified mode, with no clean escapes to "advanced"
mode.
Because you do not have a context for accessing data in the shared
state, you always have to poke whatever you want to poke from within
a lambda.
The job interface is incomplete; the idea is to be able to push a job
along as desired just by calling the lifecycle methods on the
porcelain object.
Two sets of generators are maintained. The first generators are used
when calling add_job and friends, to populate the vast majority of the
fields in the job object itself. The second bank of generators (bulk_)
are used when generating large numbers of items at once. In this case,
there are no available fields from the user at all, so the generator
needs to fill in additional data (and filling in that data can have
side effects, which is why we don't fill in and overwrite).