Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
40 changes: 40 additions & 0 deletions test/DemaConsulting.NuGet.CacheTool.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,44 @@ public void IntegrationTest_CachePackage_OutputsPath()
Assert.IsFalse(string.IsNullOrWhiteSpace(output));
Assert.DoesNotContain("Error", output);
}

/// <summary>
/// Test that attempting to cache a nonexistent package returns an error.
/// </summary>
[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);
}

/// <summary>
/// Test that specifying an invalid log file path returns an error.
/// </summary>
[TestMethod]
public void IntegrationTest_LogFlag_WithInvalidFilename_ReturnsError()
{
// Arrange - use a hard-coded path into a nonexistent directory to ensure failure
const string invalidLogPath = "/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);
}
}