Skip to content

WL-0MM8V5GTH06V9Z0P: Make delegate mock destructive and add preservation test#790

Merged
rgardler-msft merged 1 commit intomainfrom
wl-0MM8V5GTH06V9Z0P-realistic-mock
Mar 2, 2026
Merged

WL-0MM8V5GTH06V9Z0P: Make delegate mock destructive and add preservation test#790
rgardler-msft merged 1 commit intomainfrom
wl-0MM8V5GTH06V9Z0P-realistic-mock

Conversation

@rgardler-msft
Copy link
Copy Markdown
Owner

Summary

  • Makes the db.import mock in createDelegateTestContext() destructive (clear-then-insert) to match real db.import() semantics, ensuring mock-based tests would catch data-loss bugs if someone reverted the fix.
  • Adds a new test preserves non-delegated items after successful delegation that creates 3 items, delegates one, and verifies the other two still exist.

Context

Part of the fix for critical data-loss bug WL-0MM8RQOC902W3LM5. This is Feature 3 of 4:

  1. WL-0MM8V4UPC02YMFXK - Add db.upsertItems() API (PR WL-0MM8V4UPC02YMFXK: Add non-destructive db.upsertItems() API #788, merged)
  2. WL-0MM8V55PV1Q32K7D - Replace db.import() with db.upsertItems() in GitHub flows (PR WL-0MM8V55PV1Q32K7D: Fix destructive db.import() in GitHub flows #789, merged)
  3. WL-0MM8V5GTH06V9Z0P - Update mock-based tests to expose destructive behavior (this PR)
  4. WL-0MM8V5SF11MGNQNM - Audit remaining db.import() call sites and add safety docs

Test results

  • All 16 delegate-guard-rails tests pass (15 existing + 1 new)
  • Full test suite: 95 files, 1214 tests pass, 0 failures

Changes

  • tests/cli/delegate-guard-rails.test.ts: Updated db.import mock to call items.clear() before inserting (matching real semantics), added explanatory comment, added new preservation test.

…ion test

- Update db.import mock in createDelegateTestContext() to clear items
  before re-inserting, matching real db.import() semantics
- Add test verifying non-delegated items survive delegation
- This test would fail if upsertItems() were reverted to import()
@rgardler-msft rgardler-msft merged commit 1cf2469 into main Mar 2, 2026
4 checks passed
@SorraTheOrc SorraTheOrc deleted the wl-0MM8V5GTH06V9Z0P-realistic-mock branch March 10, 2026 00:42
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