Skip to content

SP-1091: replace json writes and zip file reads with real files in temp directory#376

Merged
Jing Sun (kuvia) merged 11 commits into
mainfrom
SP-1091-Content-CLI-Use-a-real-temp-filesystem-in-integration-tests
Jun 19, 2026
Merged

SP-1091: replace json writes and zip file reads with real files in temp directory#376
Jing Sun (kuvia) merged 11 commits into
mainfrom
SP-1091-Content-CLI-Use-a-real-temp-filesystem-in-integration-tests

Conversation

@kuvia

Copy link
Copy Markdown
Contributor

Description

Removed general mocking of fs, this had a lot of cascading changes, most of which are writes to JSON files that have all been replaced by real file writes. I have also replaced all mocks of zip file reading occasions in package import.

Instances where file mocks were kept are git branch and profile reads because they strictly don't read from a temp dir but from a git repo and homedir respectively. If we want to change those too I would propose to do it in a different task because the PR is big enough as is.

Relevant links

Checklist

  • I have self-reviewed this PR
  • I have tested the change and proved that it works in different scenarios
  • I have updated docs if needed

@kuvia Jing Sun (kuvia) requested review from a team as code owners June 15, 2026 11:55
Comment thread src/core/utils/file-service.ts Outdated
Comment thread tests/commands/configuration-management/config-list-variables.spec.ts Outdated
Comment thread tests/utls/fs-utils.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@kuvia Jing Sun (kuvia) merged commit 397418c into main Jun 19, 2026
6 checks passed
@kuvia Jing Sun (kuvia) deleted the SP-1091-Content-CLI-Use-a-real-temp-filesystem-in-integration-tests branch June 19, 2026 11:15
Zgjim Haziri (ZgjimHaziri) added a commit that referenced this pull request Jun 21, 2026
Integrate main's SP-1091 (#376) test-infra refactor, which replaces
mocked fs with real files in a temp directory (process.cwd() is
redirected to a temp dir; mockWriteFileSync / mockReadFileSync /
mockCreateReadStream and the fs-mock helpers are gone in favour of
tests/utls/fs-utils).

Conflicts resolved:
- src/core/utils/file-service.ts: keep SP-992's extractZipBufferToTempDirectory
  and adopt main's synchronous readFileToJson(fileName): any signature.
- single-package-export.spec.ts / single-package-import.spec.ts: rebuild the
  SP-992 Git tests on main's real-file approach (spy fs.rmSync, makeTempDir,
  zipToTempFolder, getJsonFromDownloadedFile) while keeping the gitBranch
  argument and the gitBranch-aware validation messages.

single-package-export.service.ts and file.service.spec.ts auto-merged
(SP-992 Git logic + main's resolve(process.cwd(), ...) / real-fs setup).

tsc and the full jest suite (48 suites, 434 tests) pass.

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
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