public static void PaketRestore(this ICakeContext context, PaketRestoreSettings settings) { var resolver = GetPaketToolResolver(context); var restorer = new PaketRestorer(context.FileSystem, context.Environment, context.Tools, context.ProcessRunner, resolver); restorer.Restore(settings); }
public void PaketRestoreWithBootloaderAndPaketExecutableRetrieval() { // arrange var fixture = new CakePaketRestoreAliasFixture(); var restoreSettingsDummy = new PaketRestoreSettings { RetrieveBootstrapper = true, RetrievePaketExecutable = true }; const string fakeUrl = "http://localhost:9955"; var directory = new DirectoryPath(Guid.NewGuid().ToString()); var bootstrapperPath = new FilePath(Path.Combine(directory.FullPath, PaketBootstrapper)); var transferModelDummy = new GitHubLatestReleaseTransferModel { GitHubAssetsTransferModel = new[] { new GitHubAssetsTransferModel { BrowserUrl = $"{fakeUrl}/{PaketBootstrapper}", Name = PaketBootstrapper } } }; var httpMock = HttpMockRepository.At(fakeUrl); CakePaketRestoreAlias.GithubUrlPath = fakeUrl; fixture.FileSysteMock.Setup(t => t.GetFile(bootstrapperPath).Exists).Returns(false); httpMock.Stub(x => x.Get(BootStrapperUrl)) .Return("application/json") .Return(JsonConvert.SerializeObject(transferModelDummy)) .OK(); httpMock.Stub(x => x.Get($"/{PaketBootstrapper}")) .ReturnFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "TestFile.txt")) .OK(); var act = new Action(() => fixture.GetCakeContext.PaketRestore(fixture.GetDirectoryPath, restoreSettingsDummy)); // act // assert act.ShouldNotThrow <CakeException>("Error occured during Paket restore"); fixture.GetCakeLog.Messages.Should().Contain(x => x.Format == "Completed retrieval of the Paket Bootstrapper"); DirectoryHelper.DeleteDirectory(directory.FullPath); }