-
Notifications
You must be signed in to change notification settings - Fork 4
test: Add test for DeepnoteRequirementsHelper #178
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
Signed-off-by: Tomas Kislan <tomas@kislan.sk>
📝 WalkthroughWalkthroughAdds a unit test suite for DeepnoteRequirementsHelper.node that verifies createRequirementsFile writes a requirements.txt when none exists. The test mocks VSCode workspace context, Sequence Diagram(s)sequenceDiagram
participant Test as Unit Test
participant Helper as DeepnoteRequirementsHelper
participant FS as fs.promises
participant Assert as Assertions
Note right of Test `#DDEBF7`: Setup mocks\n(workspace, token, logger)
Test->>Helper: createRequirementsFile(project, token)
Helper->>FS: access(path) -- mocked to throw (file missing)
alt file missing
Helper->>FS: writeFile(path, content) -- captured by mock
FS-->>Helper: resolve
Helper-->>Test: return success
end
Test->>Assert: verify path contains "requirements.txt"
Test->>Assert: verify captured content:
Note right of Assert `#F7F3D9`: "numpy>=1.20.0\npandas==1.3.0\nmatplotlib\n"
Assert-->>Test: pass/fail
Pre-merge checks✅ Passed checks (2 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
=====================================
Coverage 73% 73%
=====================================
Files 574 575 +1
Lines 46881 46922 +41
Branches 5521 5521
=====================================
+ Hits 34428 34488 +60
+ Misses 10635 10612 -23
- Partials 1818 1822 +4
🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts (3)
src/test/mocks/vsc/index.ts (1)
CancellationToken(100-112)src/test/vscode-mock.ts (2)
resetVSCodeMocks(60-79)mockedVSCodeNamespaces(17-17)src/platform/deepnote/deepnoteTypes.ts (1)
DeepnoteProject(12-12)
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts (3)
src/test/mocks/vsc/index.ts (1)
CancellationToken(100-112)src/test/vscode-mock.ts (2)
resetVSCodeMocks(60-79)mockedVSCodeNamespaces(17-17)src/platform/deepnote/deepnoteTypes.ts (1)
DeepnoteProject(12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & Test
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts (3)
src/test/mocks/vsc/index.ts (1)
CancellationToken(100-112)src/test/vscode-mock.ts (2)
resetVSCodeMocks(60-79)mockedVSCodeNamespaces(17-17)src/platform/deepnote/deepnoteTypes.ts (1)
DeepnoteProject(12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & Test
🔇 Additional comments (5)
src/notebooks/deepnote/deepnoteRequirementsHelper.node.unit.test.ts (5)
1-11: LGTM!Imports are clean and appropriate for the test setup.
13-19: LGTM!Test suite structure is well-defined.
20-34: LGTM!Setup correctly initializes mocks and creates the helper instance. The CancellationToken mock does not need a
thenproperty per previous discussion.Based on learnings
36-39: LGTM!Proper teardown prevents test pollution.
69-70: Good improvement with ENOENT error code.The test now uses a realistic filesystem error with the ENOENT code, improving test fidelity over the previous generic error.
Summary by CodeRabbit