Skip to content

fix(test): unbreak main — give four get edge-case fixtures a real file for #158's guardrail - #168

Merged
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/get-edge-cases-empty-files-fixtures
Aug 13, 2026
Merged

fix(test): unbreak main — give four get edge-case fixtures a real file for #158's guardrail#168
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/get-edge-cases-empty-files-fixtures

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

Main is red. Merged PR #158 (5d7eb6f, "fix(get,scan): retain patch-added new files; guard empty patch records") added a correct guardrail: a fetched patch view whose files_for_manifest map is empty is now reported as a failure (patch has no applicable files, exit 1) instead of a silent applied:1. That guardrail is correct and stays.

But #158 only edited crates/socket-patch-cli/src/commands/get.rs and did not update four tests in crates/socket-patch-cli/tests/get_edge_cases_e2e.rs whose mock patch-view fixtures use "files": {} and assert the get succeeds (exit 0). Those four now fail on current main (4f58eec):

  • get_with_id_flag_selects_specific_patch
  • get_uuid_returns_paid_patch_with_token_succeeds
  • get_on_vendored_purl_warns_about_uuid_drift
  • get_uuid_replacing_existing_manifest_entry_reports_updated

cargo test -p socket-patch-cli --test get_edge_cases_e2e was 18 passed / 4 failed on main. These four are the entire breakage — the CI test, coverage, and test-release jobs all fail on exactly these.

Fix

Fix the stale fixtures, not the guardrail. Each of these tests' real concern is selection / paid-token / drift-warning / manifest-replacement logic — the empty "files": {} was only ever a lazy stand-in, never "a patch with zero files". Each view fixture now carries one recordable net-new file (all-zero beforeHash, a real git-blob afterHash computed via the shared common::git_sha256 oracle, matching base64 blobContent), modeled on the passing get_invariants::patch_response_json fixture. This makes files_for_manifest non-empty so the guard passes. Introduced via one small single_file_view() helper reused by all four. Every existing assertion is unchanged (found == 1, the selected UUID, the drift warning naming both UUIDs, the updated action + oldUuid, the manifest actually moving to the new UUID). get.rs and the guardrail are untouched. The seed manifest's old-UUID "files": {} in the replacement test is deliberately left as-is — it is pre-existing state, never fetched or applied, so the guard does not touch it.

Test

  • cargo test -p socket-patch-cli --test get_edge_cases_e2e22/22 (was 18/4).
  • cargo test -p socket-patch-cli --lib → 350 passed, unaffected.
  • cargo test -p socket-patch-cli --test get_invariants --test get_update_summary_e2e → 15 passed, unaffected.
  • cargo build -p socket-patch-cli clean.

Scope

One file, crates/socket-patch-cli/tests/get_edge_cases_e2e.rs (+29/-4). No production code, no guardrail change, no other suite needed touching.

This PR unbreaks main and should be merged before the other open fix/* PRs. Those PRs carry stale-green CI (they branched before #158 landed the guardrail); once rebased onto current main they will inherit this same 4-test failure until this fix is in.

🤖 Generated with Claude Code


Note

Low Risk
Test-only fixture updates in one e2e file; no production or guardrail changes.

Overview
Restores four failing get_edge_cases_e2e tests on main after PR #158 made empty patch files maps fail with "patch has no applicable files" instead of succeeding silently.

Adds a shared single_file_view() helper that returns one net-new file (beforeHash all zeros, matching afterHash / base64 blob via common::git_sha256), aligned with the passing get_invariants fixture. Four mock patch-view responses swap "files": {} for single_file_view() so files_for_manifest is non-empty under --save-only. Production get.rs and the guardrail are unchanged; assertions still target --id selection, paid-token fetch, vendored UUID drift warnings, and manifest updated / oldUuid behavior.

Reviewed by Cursor Bugbot for commit 73c16dd. Configure here.

…rd passes

Merged PR #158 (5d7eb6f, "fix(get,scan): retain patch-added new files;
guard empty patch records") added a correct guardrail: a fetched patch
view whose `files_for_manifest` map is EMPTY is now an exit-1 failure
("patch has no applicable files") instead of a silent `applied:1`. But
#158 only touched get.rs and left four tests in get_edge_cases_e2e.rs
carrying stale `"files": {}` patch-view fixtures that still assert the
`get` succeeds (exit 0). Those four now fail on main:

  - get_with_id_flag_selects_specific_patch
  - get_uuid_returns_paid_patch_with_token_succeeds
  - get_on_vendored_purl_warns_about_uuid_drift
  - get_uuid_replacing_existing_manifest_entry_reports_updated

Their real concern is selection / paid-token / drift-warning /
manifest-replacement logic, not "a patch with zero files" — the empty
map was only a lazy stand-in. Give each view fixture one recordable
net-new file (all-zero `beforeHash`, real git-blob `afterHash` via the
shared `common::git_sha256` oracle, matching base64 `blobContent`),
modeled on the passing `get_invariants::patch_response_json` fixture, so
`files_for_manifest` is non-empty and the guard is satisfied. Every
existing assertion (found==1, selected UUID, drift warning, `updated`
reporting + `oldUuid`, manifest move) is unchanged. The guardrail in
get.rs is untouched.

get_edge_cases_e2e now 22/22; lib (350) and get_invariants /
get_update_summary (15) unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ardrail

Same root cause as this PR's get_edge_cases_e2e fixes: #158's guardrail
(empty applicable-files map -> "patch has no applicable files", exit 1)
broke get_emits_patch_fetched_telemetry_on_uuid_lookup_success, whose mock
patch-view used "files": {} while asserting a successful get. Give it a
recordable new-file entry (afterHash = git-blob sha256 of the decoded blob)
so the success + telemetry assertions hold; guardrail untouched. Verified
with a full `cargo test --workspace --no-fail-fast` pass that these two
binaries held the only 5 casualties, now all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit b109645 into main Aug 13, 2026
100 of 101 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/get-edge-cases-empty-files-fixtures branch August 13, 2026 18:36
Mikola Lysenko (mikolalysenko) added a commit that referenced this pull request Aug 13, 2026
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