[test-improver] Improve tests for server session directory#9882
[test-improver] Improve tests for server session directory#9882github-actions[bot] wants to merge 1 commit into
Conversation
Add three new subtests to TestEnsureSessionDirectory covering the two previously uncovered error branches in ensureSessionDirectory: - 'returns error when payloadDir is a file (MkdirAll blocked)': sets payloadDir to a regular file so Stat returns ENOTDIR (not IsNotExist), exercising the line 68-70 error path. - 'returns error when directory cannot be created (MkdirAll failure)': makes payloadDir non-writable so Stat returns IsNotExist but MkdirAll fails with permission denied, exercising the line 74-76 error path. - 'returns error on Stat failure that is not IsNotExist': uses a null byte in the session ID so Stat returns an invalid-argument error, also exercising the line 68-70 branch. Coverage for ensureSessionDirectory: 90.0% → 100.0% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds error-path coverage for session-directory creation.
Changes:
- Tests
os.Statfailures. - Tests
os.MkdirAllfailures. - Verifies contextual error messages.
Show a summary per file
| File | Description |
|---|---|
internal/server/session_test.go |
Adds session-directory failure tests. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Medium
| require.NoError(t, os.Mkdir(readOnly, 0555)) | ||
| t.Cleanup(func() { os.Chmod(readOnly, 0755) }) //nolint:errcheck |
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Notes:
Overall: PASS References: §29968714883
|
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Key Findings
References: §29968714828
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §29968714860
|
Summary
Improves test coverage for
ensureSessionDirectoryininternal/server/session.go.File Analyzed
internal/server/session_test.go—TestEnsureSessionDirectoryImprovements Made
Added three new subtests covering the two previously uncovered error branches in
ensureSessionDirectory:1.
os.Statreturns non-IsNotExisterror (line 68–70)returns error when payloadDir is a file (MkdirAll blocked): setspayloadDirto a regular file soStat("file/my-session")returnsENOTDIR— notos.IsNotExist— triggering the error path.returns error on Stat failure that is not IsNotExist: passes a null-byte session ID soStatreturns an invalid-argument error, also exercising line 68–70.2.
os.MkdirAllfails (line 74–76)returns error when directory cannot be created (MkdirAll failure): markspayloadDiras non-writable (0555) soStatcorrectly returnsIsNotExist(the subdirectory genuinely does not exist) butMkdirAllthen fails with permission denied.Coverage
ensureSessionDirectoryTest Output
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
awmgmcpgindex.crates.ioSee Network Configuration for more information.