Repository navigation
Commit 99664d0
committed
test(file-safety): pin publish-failure rethrow, restore retry count, and staging no-ops
Four review findings on this unit's own specs, each verified against the code at daee64d before being changed:
- DiffViewProvider.spec.ts: no test handed saveDirectly an ordinary publish failure, so a catch that swallowed every error would have passed the suite. The new case rejects with a plain Error and asserts the rejection propagates, the document is not opened, and no committed-write warning is logged.
- safeWriteText.spec.ts line 649: the comment said the restore is retried once while the assertion checked greater than 0, which is the shape that lets a removed retry pass. Production retries a non-privilege restore failure exactly once, so the count is now asserted exactly at 2.
- safeWriteText.spec.ts foreign-uid staging test: the comment claimed nothing is staged and nothing is published but no assertion backed it, so openSync, rename and rmdirSync are now asserted not to have been called.
- safeWriteText.spec.ts parent-directory-creation block: its beforeEach hand-copied the shared _restoreFsDefaults helper, had already lost the fs.lstat default the helper sets and repeated two mocks the helper makes, while four sibling top-level suites call the helper. It now calls the helper and keeps only the two defaults specific to that block, and the describe title no longer cites safeWriteText.ts:288-290, which at this head is the doc comment of _restoreDaclWindows while the parent-directory mkdir and access live at 471-488.
Negative controls, all run on this machine against the production code the specs pin: disabling the single restore retry turns the exact-count assertion red with expected 1 to be 2; widening the DiffViewProvider catch to swallow ordinary publish failures turns the new case red with promise resolved instead of rejecting; and the foreign-uid case, which is skipped on win32 because production reads process.getuid at safeWriteText.ts:192 and this host has none, was run once with the skip removed and getuid stubbed, where it passes, and once more with the ownership throw neutered, where it fails. Baseline over both spec files: 2 files passed, 183 passed and 1 skipped. ESLint over both changed files exits 0 with no findings, and eslint-suppressions.json is untouched.1 parent daee64d commit 99664d0
2 files changed
Lines changed: 38 additions & 20 deletions
File tree
- src
- integrations/editor/__tests__
- services/file-safety/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
917 | 937 | | |
918 | 938 | | |
919 | 939 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
646 | 648 | | |
647 | 649 | | |
648 | 650 | | |
649 | | - | |
| 651 | + | |
650 | 652 | | |
651 | 653 | | |
652 | 654 | | |
| |||
1644 | 1646 | | |
1645 | 1647 | | |
1646 | 1648 | | |
1647 | | - | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
1648 | 1654 | | |
1649 | 1655 | | |
1650 | 1656 | | |
| |||
2012 | 2018 | | |
2013 | 2019 | | |
2014 | 2020 | | |
2015 | | - | |
| 2021 | + | |
2016 | 2022 | | |
2017 | | - | |
2018 | | - | |
2019 | | - | |
2020 | | - | |
2021 | | - | |
2022 | | - | |
2023 | | - | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
2031 | 2031 | | |
2032 | | - | |
2033 | | - | |
2034 | 2032 | | |
2035 | 2033 | | |
2036 | 2034 | | |
| |||
0 commit comments