-
-
Notifications
You must be signed in to change notification settings - Fork 0
test: add logger behavior verification for file size warnings #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add integration test to verify logger.warn calls and file skipping behavior when large files are mixed with valid files in a directory fix #89
Summary of ChangesHello @KubrickCode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial integration test to validate the system's behavior when encountering oversized files during the file collection process. The test ensures that files exceeding the maximum allowed size are correctly identified and skipped, preventing their inclusion, while simultaneously confirming that other valid files in the same directory are processed as expected. This enhancement improves the robustness of the file handling logic and verifies the intended file skipping behavior. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds an integration test to verify the behavior of collectFiles when encountering files that exceed the maximum size limit. The test correctly checks that oversized files are skipped. However, it misses a key part of the intended behavior verification: ensuring that a warning is logged for each skipped file. I've added a suggestion to include this check, which will make the test more robust and fully align with the PR's goal.
| it("should skip files exceeding max size and collect valid files", async () => { | ||
| await mkdir(join(testDir, "src"), { recursive: true }); | ||
|
|
||
| const largeContent = "x".repeat(MAX_FILE_SIZE_MB * 1024 * 1024); | ||
| await writeFile(join(testDir, "src/large.ts"), largeContent); | ||
| await writeFile(join(testDir, "src/small.ts"), "small content"); | ||
|
|
||
| const files = await collectFiles("src", testDir); | ||
|
|
||
| // Should only collect the small file, skipping the large one | ||
| expect(files).toHaveLength(1); | ||
| expect(files[0]?.path).toBe("src/small.ts"); | ||
| expect(files[0]?.content).toBe("small content"); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test correctly verifies that large files are skipped, but it's missing a key verification mentioned in the pull request description: checking that logger.warn is called. To make the test complete, you should spy on logger.warn and assert that it has been called. I've also updated the test description to reflect this.
You'll need to add the following import at the top of the file:
import { logger } from "../../internal/utils/logger.js"; it("should skip files exceeding max size, log a warning, and collect valid files", async () => {
const warnSpy = jest.spyOn(logger, "warn").mockImplementation(() => {});
await mkdir(join(testDir, "src"), { recursive: true });
const largeContent = "x".repeat(MAX_FILE_SIZE_MB * 1024 * 1024);
await writeFile(join(testDir, "src/large.ts"), largeContent);
await writeFile(join(testDir, "src/small.ts"), "small content");
const files = await collectFiles("src", testDir);
// Should only collect the small file, skipping the large one
expect(files).toHaveLength(1);
expect(files[0]?.path).toBe("src/small.ts");
expect(files[0]?.content).toBe("small content");
// Should log a warning for the skipped file
expect(warnSpy).toHaveBeenCalledTimes(1);
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("exceeds maximum"));
warnSpy.mockRestore();
});## [1.0.5](v1.0.4...v1.0.5) (2025-11-20) ### 🔧 Maintenance * add logger and github-client utilities ([](6196258)), closes [#72](#72) * add logger behavior verification for file size warnings ([](06f82e9)), closes [#89](#89) * add NetworkError and ValidationError classes ([](4e09739)), closes [#71](#71) * apply barrel export pattern and clean up import paths ([](04ce850)), closes [#100](#100) * apply custom error classes to executor.ts ([](8b78d58)), closes [#73](#73) * apply custom error classes to pull/index.ts ([](ccb01b1)), closes [#74](#74) * apply logger utility across entire project ([](0821077)), closes [#72](#72) * decompose baedal function to reduce complexity ([](15db919)), closes [#74](#74) * decompose executePush function to reduce complexity ([](c2404c4)), closes [#73](#73) * enhance CLI option validation in adapter ([](15f325d)), closes [#93](#93) * implement 2-tier release notes structure ([](8c5eaf0)) * implement BaseError and FileSystemError classes (based on ts-custom-error) ([](ef2e9fc)), closes [#68](#68) * improve coverage by 12% with integration tests ([](3912f18)), closes [#75](#75) * Merge branch 'main' into develop/shlee/68 ([](5e1aec2)) * Merge pull request #101 from KubrickCode/develop/shlee/100 ([](abfe334)), closes [#101](#101) * Merge pull request #81 from KubrickCode/develop/shlee/67 ([](ebaed6a)), closes [#81](#81) * Merge pull request #82 from KubrickCode/develop/shlee/68 ([](cf27101)), closes [#82](#82) * Merge pull request #83 from KubrickCode/develop/shlee/69,70 ([](5310670)), closes [#83](#83) * Merge pull request #84 from KubrickCode/develop/shlee/71 ([](961437a)), closes [#84](#84) * Merge pull request #85 from KubrickCode/develop/shlee/72,73 ([](4fe566e)), closes [#85](#85) * Merge pull request #86 from KubrickCode/develop/shlee/74 ([](1623d2c)), closes [#86](#86) * Merge pull request #87 from KubrickCode/develop/shlee/75 ([](ecd9868)), closes [#87](#87) * Merge pull request #96 from KubrickCode/develop/shlee/88 ([](716527b)), closes [#96](#96) * Merge pull request #97 from KubrickCode/develop/shlee/89 ([](8bbd2d2)), closes [#97](#97) * Merge pull request #98 from KubrickCode/develop/shlee/90 ([](c30c5ed)), closes [#98](#98) * Merge pull request #99 from KubrickCode/develop/shlee/92 ([](0e6f4e3)), closes [#99](#99) * Merge remote-tracking branch 'origin/release' ([](3d585f5)) * move pull public types to pkg/pull/types.ts ([](82943f2)) * pnpm link command failing due to missing global environment setup ([](216c118)) * refactor extract module and add path-helpers utilities ([](3c33d1a)), closes [#69](#69) [#70](#70) * remove unused token parameter from parseSource ([](e6dc4a6)), closes [#91](#91) * reorganize internal modules into core/domain/infra/utils structure ([](c3a07d5)) * resolve immutable commit object error in transform function ([](6e1e853)) * restructure folders following NPM guidelines ([](587c956)), closes [#67](#67) * split extractTarball into strategy pattern ([](7edcb25)), closes [#92](#92) * standardize error handling in download and files modules ([](4619732)), closes [#88](#88) * unify Octokit instantiation with github-client utility ([](92ea5fd)), closes [#72](#72) * Update README ([](d64cf7e)) * Update README, CLAUDE ([](2e4d8a9)), closes [#76](#76) * utilize Provider type and improve extensibility ([](f773d1c)), closes [#90](#90)
|
🎉 This PR is included in version 1.0.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Add integration test to verify logger.warn calls and file skipping behavior when large files are mixed with valid files in a directory
fix #89