Skip to content

test: zone_record routes survive a leftover row - #76

Merged
msimerson merged 1 commit into
NicTool:mainfrom
aberoham:zone-record-test-leftover
Oct 14, 2026
Merged

msimerson merged 1 commit into
NicTool:mainfrom
aberoham:zone-record-test-leftover

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

One leftover zone record with id 5097 makes routes/zone_record.test.js run forever. before() destroys the test record and zone, but not the bystander record it creates next. So ZoneRecord.create() throws a conflict. after() then calls stop() on a server that never started. The open db connection keeps node running.

Both halves came from my PRs on Aug 30. #71 added the bystander, and #69 made create() reject an existing id instead of returning it.

A crashed earlier run leaves that row behind, and so does a restored production db that has a record at 5097. before() now destroys the bystander first. If setup still fails, after() closes the db connection so the file fails instead of hanging.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup can delete legitimate data, and the fallback does not await database disconnection.

2 open findings
What changed in this PR

Improves zone-record route-test cleanup after stale fixtures or setup failures.

Changes:

  • Removes the bystander fixture before setup.
  • Disconnects the database when server initialization fails.
File Description
routes/​zone_record.test.js Updates fixture cleanup and failed-setup teardown.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


before(async () => {
await ZoneRecord.destroy({ id: testZoneRecordId })
await ZoneRecord.destroy({ id: bystanderId })
await server.stop()
// a failed before() leaves no server, and an open db connection keeps node running
if (server) await server.stop()
else await ZoneRecord.disconnect()
@msimerson
msimerson merged commit da3a2cb into NicTool:main Oct 14, 2026
10 checks passed
msimerson added a commit to aberoham/api that referenced this pull request Oct 14, 2026
routes/zone_record.test.js (NicTool#76) awaits ZoneRecord.disconnect() after a
failed setup; without the return, that await settled before the
connection closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
msimerson added a commit to aberoham/api that referenced this pull request Oct 14, 2026
routes/zone_record.test.js (NicTool#76) awaits ZoneRecord.disconnect() after a
failed setup; without the return, that await settled before the
connection closed.
@aberoham
aberoham deleted the zone-record-test-leftover branch October 14, 2026 19:54
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.

3 participants