Enabling E2E tests by setting HOME and USERPROFILE env variables. This will cause the NuGet.Config and fallback folder to be extract to the location in those variables during the tests. Also refactored all NuGet path calculators for the first run to a single place.
This commit is contained in:
parent
a46237784e
commit
0c1af8a2fe
6 changed files with 47 additions and 23 deletions
|
@ -26,8 +26,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
private Mock<INuGetPackagesArchiver> _nugetPackagesArchiverMock;
|
||||
private Mock<INuGetCacheSentinel> _nugetCacheSentinel;
|
||||
private Mock<INuGetConfig> _nugetConfigMock;
|
||||
|
||||
private string _nuGetFallbackFolder;
|
||||
private CLIFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
|
||||
|
||||
public GivenANuGetCachePrimer()
|
||||
{
|
||||
|
@ -43,15 +42,15 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
|
||||
_nugetConfigMock = new Mock<INuGetConfig>();
|
||||
|
||||
_cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator();
|
||||
|
||||
var nugetCachePrimer = new NuGetCachePrimer(
|
||||
_nugetPackagesArchiverMock.Object,
|
||||
_nugetCacheSentinel.Object,
|
||||
_nugetConfigMock.Object,
|
||||
_cliFallbackFolderPathCalculator,
|
||||
_fileSystemMock.File);
|
||||
|
||||
var cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator();
|
||||
_nuGetFallbackFolder = cliFallbackFolderPathCalculator.CLIFallbackFolderPath;
|
||||
|
||||
nugetCachePrimer.PrimeCache();
|
||||
}
|
||||
|
||||
|
@ -68,6 +67,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
nugetPackagesArchiverMock.Object,
|
||||
_nugetCacheSentinel.Object,
|
||||
_nugetConfigMock.Object,
|
||||
_cliFallbackFolderPathCalculator,
|
||||
fileSystemMock.File);
|
||||
|
||||
nugetCachePrimer.PrimeCache();
|
||||
|
@ -78,13 +78,17 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
[Fact]
|
||||
public void It_adds_the_fallback_folder_to_NuGet_Config()
|
||||
{
|
||||
_nugetConfigMock.Verify(n => n.AddCLIFallbackFolder(_nuGetFallbackFolder), Times.Exactly(1));
|
||||
_nugetConfigMock.Verify(n =>
|
||||
n.AddCLIFallbackFolder(_cliFallbackFolderPathCalculator.CLIFallbackFolderPath),
|
||||
Times.Exactly(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_extracts_the_archive_to_the_fallback_folder()
|
||||
{
|
||||
_nugetPackagesArchiverMock.Verify(n => n.ExtractArchive(_nuGetFallbackFolder), Times.Exactly(1));
|
||||
_nugetPackagesArchiverMock.Verify(n =>
|
||||
n.ExtractArchive(_cliFallbackFolderPathCalculator.CLIFallbackFolderPath),
|
||||
Times.Exactly(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -104,6 +108,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
nugetPackagesArchiveMock.Object,
|
||||
nugetCacheSentinel.Object,
|
||||
_nugetConfigMock.Object,
|
||||
_cliFallbackFolderPathCalculator,
|
||||
_fileSystemMock.File);
|
||||
|
||||
Action action = () => nugetCachePrimer.PrimeCache();
|
||||
|
|
|
@ -19,23 +19,24 @@ namespace Microsoft.DotNet.Tests
|
|||
{
|
||||
private static CommandResult _firstDotnetNonVerbUseCommandResult;
|
||||
private static CommandResult _firstDotnetVerbUseCommandResult;
|
||||
private static DirectoryInfo _nugetCacheFolder;
|
||||
private static DirectoryInfo _nugetFallbackFolder;
|
||||
|
||||
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
||||
{
|
||||
var testDirectory = TestAssets.CreateTestDirectory("Dotnet_first_time_experience_tests");
|
||||
var testNugetCache = Path.Combine(testDirectory.FullName, "nuget_cache");
|
||||
var testNuGetHome = Path.Combine(testDirectory.FullName, "nuget_home");
|
||||
|
||||
var command = new DotnetCommand()
|
||||
.WithWorkingDirectory(testDirectory);
|
||||
command.Environment["NUGET_PACKAGES"] = testNugetCache;
|
||||
command.Environment["HOME"] = testNuGetHome;
|
||||
command.Environment["USERPROFILE"] = testNuGetHome;
|
||||
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
||||
command.Environment["SkipInvalidConfigurations"] = "true";
|
||||
|
||||
_firstDotnetNonVerbUseCommandResult = command.ExecuteWithCapturedOutput("--info");
|
||||
_firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive");
|
||||
|
||||
_nugetCacheFolder = new DirectoryInfo(testNugetCache);
|
||||
_nugetFallbackFolder = new DirectoryInfo(Path.Combine(testNuGetHome, ".dotnet", "NuGetFallbackFolder"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -82,7 +83,7 @@ A command is running to initially populate your local package cache, to improve
|
|||
[Fact]
|
||||
public void ItCreatesASentinelFileUnderTheNuGetCacheFolder()
|
||||
{
|
||||
_nugetCacheFolder
|
||||
_nugetFallbackFolder
|
||||
.Should()
|
||||
.HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
|
||||
}
|
||||
|
@ -115,11 +116,11 @@ A command is running to initially populate your local package cache, to improve
|
|||
"microsoft.visualstudio.web.browserlink",
|
||||
};
|
||||
|
||||
_nugetCacheFolder
|
||||
_nugetFallbackFolder
|
||||
.Should()
|
||||
.HaveDirectories(expectedDirectories);
|
||||
|
||||
_nugetCacheFolder
|
||||
_nugetFallbackFolder
|
||||
.Should()
|
||||
.NotHaveDirectories(unexpectedDirectories);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue