fix(test): leave the project as mxcli test found it - #61
Merged
Conversation
…endixlabs#803/mendixlabs#804) Three defects in one teardown, which together left a tested project permanently mutated. quotes before trailing punctuation, and DESCRIBE SETTINGS separates properties with commas, so AfterStartupMicroflow = 'MyFirstModule.ASU_Startup', parsed to `MyFirstModule.ASU_Startup',` and the restore statement became ALTER SETTINGS MODEL AfterStartupMicroflow = 'MyFirstModule.ASU_Startup',' which does not parse. The failure printed as a warning, so the run looked clean while the project was left pointing at MxTest.TestRunner — the microflow cleanup then deleted. Trailing `,;` now comes off before the quotes, the value is re-emitted through a helper that doubles embedded quotes (Mendix's escape, never backslashes), and cleanup returns its errors instead of printing them: a failed restore now fails the run and names what was left changed. so an empty module accumulated on every run. It now drops the module — but only when the run created it. CREATE MODULE is idempotent, so a project that already had its own MxTest module would otherwise have had it deleted; that case still removes just the generated microflow. Cleanup also re-checks that the module is present, so a run that failed before injection landed does not report a spurious cleanup failure. hardcoded PRODUCTION, silently changing projects that legitimately run at another level, and breaking any project whose published REST/OData services use custom authentication ("App security is off, but custom authentication is enabled for this service"). The after-startup microflow runs in an administrative context and is not subject to the Security Level, so this bought nothing. It is gone; the setting is the project's business. What cleanup must restore is now captured in a projectState before the first mutation, and the setup/cleanup statements are built by pure functions, so the restore is testable without a project or Docker. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
…eanup-802-804 # Conflicts: # .claude/skills/fix-issue.md
…eanup-802-804 # Conflicts: # .claude/skills/fix-issue.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes
mendixlabs/mxcli#802,#803and#804. Split out of #57.(Issue numbers refer to
mendixlabs/mxcli, not this fork.)Three separately-reported defects that turn out to be one teardown routine — ~60 lines of
cmd/mxcli/testrunner/runner.go. They share a singleprojectStaterefactor, which is why they land as one commit.mendixlabs#803 — the after-startup setting was never restored
DESCRIBE SETTINGSseparates properties with commas, andgetAfterStartuptrimmed quotes before punctuation:Printed as a warning, so the run read as clean while the project was left pointing at
MxTest.TestRunner— the microflow cleanup then deleted.Trailing
,;now comes off first, the value is re-emitted through a helper that doubles embedded quotes (Mendix's escape, never backslashes), and cleanup returns its errors: a failed restore now fails the run and names what was left changed.mendixlabs#804 — the orphaned MxTest module
Fixed, but not the way the issue proposed.
CREATE MODULEis idempotent — it prints "already exists" and reuses it — so an unconditionalDROP MODULE MxTestwould delete a user's ownMxTestmodule along with everything in it. The run now records whether it created the module and drops it only in that case; otherwise it removes just the generated microflow.DROP MODULEalso errors on a missing module, so cleanup re-checks presence first — otherwise a run that failed before injection landed would report a cleanup failure that never happened.mendixlabs#802 — the Security Level
Removed entirely, as the reporter suggested. Their finding checks out: the after-startup microflow runs in an administrative context and is not subject to the Security Level, so forcing it OFF bought nothing while breaking custom-auth REST/OData services — and the restore hardcoded
PRODUCTION, silently changing projects that legitimately run at another level.Testing
make build,make test,make lint,make check-mdlpass on this branch alone.The runner shells out to
mxcliand needs Docker, so the setup and cleanup statements are now built by pure functions and the tests assert the actual command lists — including that neither mentionsSECURITY LEVEL. (My first instinct was to scan the source text for it; that was wrong and is not what landed.) The repaired restore statement andDROP MODULEwere verified against a real project directly..claude/skills/mendix/test-microflows.mdhad a stale "Sets security OFF … Restores original security" description; corrected.Note
The mendixlabs#802 reporter said they have a working fix ready to submit — worth a comment on the issue before this goes upstream so the work isn't duplicated.
🤖 Generated with Claude Code
https://claude.ai/code/session_012XR649rKk68z6gBpngu6MA
Generated by Claude Code