From 3d820a2993fec7dfa5689c676f60655651295905 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:28:29 +0000 Subject: [PATCH 1/4] Initial plan From e5d79f78a23c845d905ef131096d7a53faed6a49 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:32:54 +0000 Subject: [PATCH 2/4] Add integration tests for nonexistent package and invalid log file Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> --- requirements.yaml | 2 + .../IntegrationTests.cs | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/requirements.yaml b/requirements.yaml index a139c2c..b12a41f 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -106,6 +106,7 @@ sections: tests: - Context_Create_LogFlag_OpensLogFile - IntegrationTest_LogFlag_WritesOutputToFile + - IntegrationTest_LogFlag_WithInvalidFilename_ReturnsError - id: NC-CLI-008 title: The tool shall cache NuGet packages specified as [package-name]:[version] arguments. @@ -127,6 +128,7 @@ sections: - Context_WriteError_SetsErrorExitCode - Context_WriteError_NotSilent_WritesToConsole - IntegrationTest_UnknownArgument_ReturnsError + - IntegrationTest_CacheNonexistentPackage_ReturnsError - id: NC-CLI-010 title: The tool shall reject unknown or malformed command-line arguments with a descriptive error. diff --git a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs index 3ea0437..0121948 100644 --- a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs +++ b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs @@ -268,4 +268,44 @@ public void IntegrationTest_CachePackage_OutputsPath() Assert.IsFalse(string.IsNullOrWhiteSpace(output)); Assert.DoesNotContain("Error", output); } + + /// + /// Test that attempting to cache a nonexistent package returns an error. + /// + [TestMethod] + public void IntegrationTest_CacheNonexistentPackage_ReturnsError() + { + // Act + var exitCode = Runner.Run( + out var output, + "dotnet", + _dllPath, + "DemaConsulting.NonExistent.Package.XYZ:99.99.99"); + + // Assert + Assert.AreNotEqual(0, exitCode); + Assert.Contains("Error", output); + } + + /// + /// Test that specifying an invalid log file path returns an error. + /// + [TestMethod] + 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"); + + // Act + var exitCode = Runner.Run( + out var output, + "dotnet", + _dllPath, + "--log", + invalidLogPath); + + // Assert + Assert.AreNotEqual(0, exitCode); + Assert.Contains("Error", output); + } } From 886a8177249062501c470534966aa309c829ec3a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:46:22 +0000 Subject: [PATCH 3/4] Fix CodeQL: replace Path.Combine with hard-coded platform-specific paths Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> --- .../IntegrationTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs index 0121948..b38bc0e 100644 --- a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs +++ b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs @@ -293,8 +293,10 @@ public void IntegrationTest_CacheNonexistentPackage_ReturnsError() [TestMethod] 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"); + // Arrange - use a hard-coded path into a nonexistent directory to ensure failure + var invalidLogPath = OperatingSystem.IsWindows() + ? @"C:\nonexistent_dir_xyz_abc\invalid.log" + : "/nonexistent_dir_xyz_abc/invalid.log"; // Act var exitCode = Runner.Run( From b13c5f762485dfbce1026ab40e04a7615a7d05e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:50:19 +0000 Subject: [PATCH 4/4] Simplify invalid log path to single cross-platform const string Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> --- test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs index b38bc0e..7989349 100644 --- a/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs +++ b/test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs @@ -294,9 +294,7 @@ public void IntegrationTest_CacheNonexistentPackage_ReturnsError() public void IntegrationTest_LogFlag_WithInvalidFilename_ReturnsError() { // Arrange - use a hard-coded path into a nonexistent directory to ensure failure - var invalidLogPath = OperatingSystem.IsWindows() - ? @"C:\nonexistent_dir_xyz_abc\invalid.log" - : "/nonexistent_dir_xyz_abc/invalid.log"; + const string invalidLogPath = "/nonexistent_dir_xyz_abc/invalid.log"; // Act var exitCode = Runner.Run(