Skip to content

fix(test): leave the project as mxcli test found it - #61

Merged
ako merged 3 commits into
mainfrom
claude/test-runner-cleanup-802-804
Jul 31, 2026
Merged

fix(test): leave the project as mxcli test found it#61
ako merged 3 commits into
mainfrom
claude/test-runner-cleanup-802-804

Conversation

@ako

@ako ako commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Fixes mendixlabs/mxcli#802, #803 and #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 single projectState refactor, which is why they land as one commit.

mendixlabs#803 — the after-startup setting was never restored

DESCRIBE SETTINGS separates properties with commas, and getAfterStartup trimmed quotes before punctuation:

input:   AfterStartupMicroflow = 'MyFirstModule.ASU_Startup',
parsed:  MyFirstModule.ASU_Startup',
restore: ALTER SETTINGS MODEL AfterStartupMicroflow = 'MyFirstModule.ASU_Startup','
→ Parse error: mismatched input '<EOF>' expecting IDENTIFIER

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 MODULE is idempotent — it prints "already exists" and reuses it — so an unconditional DROP MODULE MxTest would delete a user's own MxTest module 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 MODULE also 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-mdl pass on this branch alone.

The runner shells out to mxcli and 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 mentions SECURITY LEVEL. (My first instinct was to scan the source text for it; that was wrong and is not what landed.) The repaired restore statement and DROP MODULE were verified against a real project directly.

.claude/skills/mendix/test-microflows.md had 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

…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
claude added 2 commits July 30, 2026 23:25
…eanup-802-804

# Conflicts:
#	.claude/skills/fix-issue.md
…eanup-802-804

# Conflicts:
#	.claude/skills/fix-issue.md
@ako
ako merged commit 27aaedf into main Jul 31, 2026
3 checks passed
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.

2 participants