Merge pull request #8379 from peterhuene/install-tool-source-option

Add source option to install tool command.
This commit is contained in:
William Lee 2018-01-12 17:46:08 -08:00 committed by GitHub
commit a3aa6dc1c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 423 additions and 43 deletions

View file

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Reflection;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.Extensions.EnvironmentAbstractions;
@ -207,6 +208,32 @@ namespace Microsoft.DotNet.ToolPackage.Tests
}
[Fact]
public void GivenASourceItCanObtainThePackageFromThatSource()
{
var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName());
var packageObtainer = ConstructDefaultPackageObtainer(toolsPath);
var toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath(
packageId: TestPackageId,
packageVersion: TestPackageVersion,
targetframework: _testTargetframework,
source: Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"TestAssetLocalNugetFeed"));
var executable = toolConfigurationAndExecutableDirectory
.ExecutableDirectory
.WithFile(
toolConfigurationAndExecutableDirectory
.Configuration
.ToolAssemblyEntryPoint);
File.Exists(executable.Value)
.Should()
.BeTrue(executable + " should have the executable");
}
private static readonly Func<FilePath> GetUniqueTempProjectPathEachTest = () =>
{
var tempProjectDirectory =
@ -229,12 +256,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests
private static FilePath WriteNugetConfigFileToPointToTheFeed()
{
var nugetConfigName = "nuget.config";
var executeDirectory =
Path.GetDirectoryName(
System.Reflection
.Assembly
.GetExecutingAssembly()
.Location);
var executeDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var tempPathForNugetConfigWithWhiteSpace =
Path.Combine(Path.GetTempPath(),

View file

@ -48,5 +48,16 @@ namespace Microsoft.DotNet.Tests.ParserTests
parseResult.ValueOrDefault<string>("configfile").Should().Be(@"C:\TestAssetLocalNugetFeed");
parseResult.ValueOrDefault<string>("framework").Should().Be("netcoreapp2.0");
}
[Fact]
public void InstallToolParserCanParseSourceOption()
{
const string expectedSourceValue = "TestSourceValue";
var result = Parser.Instance.Parse($"dotnet install tool --source {expectedSourceValue} console.test.app");
var appliedOptions = result["dotnet"]["install"]["tool"];
appliedOptions.ValueOrDefault<string>("source").Should().Be(expectedSourceValue);
}
}
}