Skip to content

Commit 5c42f9d

Browse files
Copilotdsplaisted
andcommitted
Update test coverage for tool manifest consumption - maintain backward compatibility
Co-authored-by: dsplaisted <[email protected]>
1 parent 610c1b8 commit 5c42f9d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

test/dotnet-new.IntegrationTests/TemplateDiscoveryTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public TemplateDiscoveryTool(IMessageSink messageSink)
1515
testOutputHelper = new SharedTestOutputHelper(messageSink);
1616
string home = Utilities.CreateTemporaryFolder("home");
1717
dotnetNewTestExecutionDir = Utilities.GetTestExecutionTempFolder();
18-
string toolManifestPath = Path.Combine(dotnetNewTestExecutionDir, @".config\dotnet-tools.json");
18+
string toolManifestPath = Path.Combine(dotnetNewTestExecutionDir, "dotnet-tools.json");
1919
if (!File.Exists(toolManifestPath))
2020
{
2121
new DotnetNewCommand(

test/dotnet.Tests/CommandTests/Tool/Install/ToolInstallLocalCommandTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,26 @@ out ToolCommand restoredCommand
315315
"But restore do not need to 'revert' since it just set in nuget global directory");
316316
}
317317

318+
[Fact]
319+
public void WhenRunWithExistingManifestInConfigDirectoryItShouldAddToExistingManifest()
320+
{
321+
// Test backward compatibility: ensure tools can be added to existing manifests in .config directories
322+
_fileSystem.File.Delete(_manifestFilePath);
323+
var configDirectory = Path.Combine(_temporaryDirectory, ".config");
324+
_fileSystem.Directory.CreateDirectory(configDirectory);
325+
var configManifestPath = Path.Combine(configDirectory, "dotnet-tools.json");
326+
_fileSystem.File.WriteAllText(configManifestPath, _jsonContent);
327+
328+
var toolInstallLocalCommand = GetDefaultTestToolInstallLocalCommand();
329+
330+
toolInstallLocalCommand.Execute().Should().Be(0);
331+
332+
// Verify the tool was added to the existing .config manifest
333+
var manifestPackages = _toolManifestFinder.Find();
334+
manifestPackages.Should().HaveCount(1);
335+
manifestPackages.First().PackageId.Should().Be(_packageIdA);
336+
}
337+
318338
private ToolInstallLocalCommand GetDefaultTestToolInstallLocalCommand()
319339
{
320340
return new ToolInstallLocalCommand(

0 commit comments

Comments
 (0)