Skip to content

27: Assert which mistake was reported, not that one was - #41

Open
nikolaystrikhar wants to merge 1 commit into
26-boot-idempotencefrom
27-incorrect-usage-assertions
Open

27: Assert which mistake was reported, not that one was#41
nikolaystrikhar wants to merge 1 commit into
26-boot-idempotencefrom
27-incorrect-usage-assertions

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: Tests\Support\Traits\WithIncorrectUsage records the reported message and offers an assertion that matches it; LoaderTest and Boot\SchedulerTest use it, and the late-boot fallback gains an ordering assertion.

Usage:

$this->assert_the_library_reported_incorrect_usage_saying(
    'The registered sub-plugins could not be read, so no conflict was resolved',
    'The duplicate slug is what stood the conflict pass down.'
);

Why this way:

"A report happened" is not an assertion about the cause. Four Loader cases and both resolve_conflicts() catch arms passed on a report from anything at all — deleting the Config_Exception arm outright left the suite green.

The recorder already existed, privately, in one file. It moves to the trait rather than being copied, since the loose assertion still suits callers that only need it.

expect_incorrect_usage() was leaking listeners. run_halted_request() calls it, so two halted requests in one scenario stranded a listener bound to a finished test object on doing_it_wrong_run for the rest of the process.

The inline fallback was asserted for the load and not the conflict step, so a fallback iterating only the last element of sequence() passed everything — the case where losing conflict resolution means both copies load and the request fatals.

assert_the_library_reported_incorrect_usage() accepted any report naming this
library, so four Loader cases and both Scheduler catch arms passed on a report
from an unrelated cause -- and deleting the Config_Exception arm from
resolve_conflicts() left the suite green.

The trait records the message now and offers an assertion that matches it, so
LoaderTest's private copy of that recorder goes away. expect_incorrect_usage()
also removes a listener it already installed: run_halted_request() calls it, so
two halted requests in one scenario stranded a listener bound to a finished
test object on doing_it_wrong_run for the rest of the process.

The late-boot fallback is asserted for the conflict step as well as the load,
through a should_load filter reading state at the load pass's last gate. A
fallback that iterated only the last element of sequence() passed everything.
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