Add integration tests for nonexistent package caching and invalid log file path#9
Merged
Malcolmnixon merged 4 commits intomainfrom Mar 1, 2026
Merged
Conversation
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add missing integration tests for coverage
Add integration tests for nonexistent package caching and invalid log file path
Mar 1, 2026
Malcolmnixon
requested changes
Mar 1, 2026
| public void IntegrationTest_LogFlag_WithInvalidFilename_ReturnsError() | ||
| { | ||
| // Arrange - use a path into a nonexistent directory to ensure failure | ||
| var invalidLogPath = Path.Combine(Path.GetTempPath(), "nonexistent_dir_xyz_abc", "invalid.log"); |
Contributor
There was a problem hiding this comment.
This Path.Combine will trigger CodeQL issues. Consider hard-coding the full path.
Contributor
Author
There was a problem hiding this comment.
Fixed in 886a817 — replaced Path.Combine(Path.GetTempPath(), ...) with fully hard-coded platform-specific paths:
var invalidLogPath = OperatingSystem.IsWindows()
? @"C:\nonexistent_dir_xyz_abc\invalid.log"
: "/nonexistent_dir_xyz_abc/invalid.log";CodeQL confirms 0 alerts.
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two error paths in
RunToolLogicandContext.OpenLogFilehad no integration test coverage.Description
IntegrationTest_CacheNonexistentPackage_ReturnsError— exercises the path whereNuGetCache.EnsureCachedAsyncthrowsInvalidOperationExceptionfor an unknown package; asserts non-zero exit code and"Error"in outputIntegrationTest_LogFlag_WithInvalidFilename_ReturnsError— exercisesContext.OpenLogFilefailure by passing a path into a nonexistent directory (/nonexistent_dir_xyz_abc/invalid.log); asserts non-zero exit code and"Error"in output. Path is a hard-coded const — noPath.Combine— to avoid CodeQL path-traversal alerts; works cross-platform since Windows resolves root-relative paths to the current drive.requirements.yaml— linked new tests to NC-CLI-009 (error reporting) and NC-CLI-007 (log flag)Type of Change
Pre-Submission Checklist
Build and Test
dotnet build --configuration Releasedotnet test --configuration Releasedotnet run --project src/DemaConsulting.NuGet.CacheTool --configuration Release --framework net10.0--no-build -- --validateCode Quality
dotnet format --verify-no-changesQuality Checks
cspell "**/*.{md,cs}"markdownlint "**/*.md"yamllint .Testing
Documentation
Additional Notes
Test count increases from 43 to 45 per framework (.NET 8/9/10). CodeQL reports 0 alerts.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.