Skip to content

fix(testing): honor allowTestsAgainstPrimaryDatasource when useTestDB is omitted - #4648

Merged
bpamiri merged 1 commit into
developfrom
fix/4642-4643-tests-primary-ds
Oct 26, 2026
Merged

bpamiri merged 1 commit into
developfrom
fix/4642-4643-tests-primary-ds

Conversation

@bpamiri

@bpamiri bpamiri commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4643 and #4642. Both come from the same rule: an app test run that omits useTestDB should follow set(allowTestsAgainstPrimaryDatasource=true) instead of silently swapping to <datasource>_test.

  • fix(testing): $testDataSourceDecision should prioritize allowTestsAgainstPrimaryDatasource when useTestDB is omitted #4643 — $testDataSourceDecision() (vendor/wheels/global/util.cfm): the registered candidateRegistered check returned "swap" before the allowPrimary block, so the documented 4.2 behavior was unreachable whenever a <datasource>_test existed. For an omitted useTestDB, the opt-out is now checked first: primary + warn=true even when the test datasource is registered. Explicit useTestDB=true still requires the test datasource (refused when missing); explicit useTestDB=false still targets the primary; a present-but-invalid value is still treated as not-omitted.
  • fix(debugbar): DebugBar test runner and full runner link should respect allowTestsAgainstPrimaryDatasource / pass useTestDB=false #4642 — DebugBar Test Suite panel (vendor/wheels/events/onrequestend/debug.cfm): both the "Open full runner" link and the in-page JSON runner URL are now built from the same setting — they append useTestDB=false when the app allows primary-datasource tests, and stay byte-for-byte as before when it does not.
  • Framework suite unchanged: $coreTestDataSource() now passes ignoreAllowPrimary to the decision, so the framework's own runner keeps its rule (use <primary>_test when registered, refuse when missing) and still logs the "ignores allowTestsAgainstPrimaryDatasource" warning. This was caught by the existing CoreTestRunnerDataSourceSpec — without the opt-out, a registered test datasource made the core runner refuse.

No public API change ($-prefixed internal helpers only).

Behaviour matrix ($testDataSourceDecision)

useTestDB allowPrimary candidate registered before after
omitted true yes swap (setting ignored — bug) primary + warn
omitted true no primary + warn primary + warn
omitted false yes swap swap
omitted false no refuse refuse
true true/false yes swap swap
true true/false no refuse refuse
false true/false either primary primary
invalid ("maybe") true yes swap swap
invalid ("maybe") true no refuse refuse

Regression specs

  • dispatch/ProjectTestRunnerDataSourceSpec.cfc — 7 new cases covering omitted/true/false × allowPrimary on/off × candidate registered/not (including the non-boolean value). The omitted + allowPrimary + registered case fails on the parent commit (Expected [primary] but received [swap]) and passes with the fix.
  • events/DebugBarTestRunnerUrlSpec.cfc (new) — renders debug.cfm through $includeAndReturnOutput() with the same request mock the other DebugBar specs use, and asserts the href and window.wdbTests.runUrl strings: both carry useTestDB=false when the setting is on; neither carries it when off. Fails on the parent commit (href="/wheels/app/tests" without the flag) and passes with the fix. There is a test seam for this panel, so no manual curl was needed to cover it.

Failing-then-passing with both production diffs stashed: decision spec 1 failed, DebugBar spec 1 failed; with the fix both green.

Tests

  • bash tools/test-local.sh (full core suite) → 7357 passed
  • Affected areas: dispatch 268, internal 120, events 208 — all green
  • tools/test-matrix.sh lucee7 sqlite + lucee6,adobe2023,boxlang sqlite and RustCFML run: results appended below before review.

Changelog

changelog.d/4642-4643-tests-primary-datasource.fixed.md.

Fixes #4642
Fixes #4643

… useTestDB

#4643: $testDataSourceDecision() returned "swap" as soon as <primary>_test was
registered, before consulting allowTestsAgainstPrimaryDatasource, so the
documented 4.2 behavior was unreachable whenever a test datasource existed.
For an omitted useTestDB the opt-out is checked first and runs on the primary
datasource with a warning; explicit useTestDB=true still requires the test
datasource and explicit useTestDB=false still targets the primary. The
framework's own suite passes ignoreAllowPrimary, so it keeps using
<primary>_test and still refuses when it is missing.

#4642: the DebugBar Test Suite panel's "Open full runner" link and in-page JSON
runner URL now include useTestDB=false when the app allows tests against the
primary datasource, so the same decision applies there; otherwise both URLs are
unchanged.

Regression specs cover the omitted/true/false x allowPrimary x candidate
combinations and render the debug bar to assert both URLs.

Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri bpamiri changed the title fix(testing): honor allowTestsAgainstPrimaryDatasource for an omitted useTestDB (incl. DebugBar links) fix(testing): honor allowTestsAgainstPrimaryDatasource when useTestDB is omitted Oct 26, 2026
@bpamiri
bpamiri merged commit 511dd17 into develop Oct 26, 2026
26 of 27 checks passed
@bpamiri
bpamiri deleted the fix/4642-4643-tests-primary-ds branch October 26, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant