public async Task NoUpdatersRegisteredSuccessfullyDoesNothing() { // start with nothing "installed", so checking what was installed can happen. MockInstaller installer = new MockInstaller(); IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor() { Details = new Dictionary <string, string>(), FactoryId = NupkgInstallUnitDescriptorFactory.FactoryId, Identifier = "MockPackage", MountPointId = new Guid("C5A4D83F-7005-4B38-BF47-DFF5CB5F5881"), }; CliTemplateUpdater updater = new CliTemplateUpdater(EngineEnvironmentSettings, installer, "new"); Assert.Empty(installer.Installed); List <IInstallUnitDescriptor> installsToUpdate = new List <IInstallUnitDescriptor>() { installDescriptor }; bool updateResult = await updater.CheckForUpdatesAsync(installsToUpdate, true); Assert.True(updateResult); Assert.Empty(installer.Installed); }
public async Task UpdateIsFoundAndApplied() { EngineEnvironmentSettings.SettingsLoader.Components.Register(typeof(MockNupkgUpdater)); IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor() { Details = new Dictionary <string, string>(), FactoryId = NupkgInstallUnitDescriptorFactory.FactoryId, Identifier = "MockPackage", MountPointId = new Guid("C5A4D83F-7005-4B38-BF47-DFF5CB5F5881"), }; List <IInstallUnitDescriptor> installsToUpdate = new List <IInstallUnitDescriptor>() { installDescriptor }; IUpdateUnitDescriptor updateDescriptor = new UpdateUnitDescriptor(installDescriptor, "MockPackageToInstall", "Mock Package To Install"); MockNupkgUpdater.SetMockUpdates(new List <IUpdateUnitDescriptor>() { updateDescriptor }); // start with nothing "installed", so checking what was installed can happen. MockInstaller installer = new MockInstaller(); CliTemplateUpdater updater = new CliTemplateUpdater(EngineEnvironmentSettings, installer, "new"); Assert.Empty(installer.Installed); bool updateResult = await updater.CheckForUpdatesAsync(installsToUpdate, true); Assert.True(updateResult); Assert.Single(installer.Installed); }
private async Task <CreationResultStatus> ExecuteAsync() { // this is checking the initial parse, which is template agnostic. if (_commandInput.HasParseError) { return(HelpForTemplateResolution.HandleParseError(_commandInput, _telemetryLogger)); } if (_commandInput.IsHelpFlagSpecified) { _telemetryLogger.TrackEvent(CommandName + TelemetryConstants.HelpEventSuffix); } if (_commandInput.ShowAliasesSpecified) { return(AliasSupport.DisplayAliasValues(EnvironmentSettings, _commandInput, _aliasRegistry, CommandName)); } if (_commandInput.ExpandedExtraArgsFiles && string.IsNullOrEmpty(_commandInput.Alias)) { // Only show this if there was no alias expansion. // ExpandedExtraArgsFiles must be checked before alias expansion - it'll get reset if there's an alias. Reporter.Output.WriteLine(string.Format(LocalizableStrings.ExtraArgsCommandAfterExpansion, string.Join(" ", _commandInput.Tokens))); } if (string.IsNullOrEmpty(_commandInput.Alias)) { // The --alias param is for creating / updating / deleting aliases. // If it's not present, try expanding aliases now. CreationResultStatus aliasExpansionResult = AliasSupport.CoordinateAliasExpansion(_commandInput, _aliasRegistry, _telemetryLogger); if (aliasExpansionResult != CreationResultStatus.Success) { return(aliasExpansionResult); } } if (!ConfigureLocale()) { return(CreationResultStatus.InvalidParamValues); } if (!Initialize()) { return(CreationResultStatus.Success); } try { bool isHiveUpdated = SyncOptionalWorkloads(); if (isHiveUpdated) { Reporter.Output.WriteLine(LocalizableStrings.OptionalWorkloadsSynchronized); } } catch (HiveSynchronizationException hiex) { Reporter.Error.WriteLine(hiex.Message.Bold().Red()); } bool forceCacheRebuild = _commandInput.HasDebuggingFlag("--debug:rebuildcache"); try { _settingsLoader.RebuildCacheFromSettingsIfNotCurrent(forceCacheRebuild); } catch (EngineInitializationException eiex) { Reporter.Error.WriteLine(eiex.Message.Bold().Red()); Reporter.Error.WriteLine(LocalizableStrings.SettingsReadError); return(CreationResultStatus.CreateFailed); } try { if (!string.IsNullOrEmpty(_commandInput.Alias) && !_commandInput.IsHelpFlagSpecified) { return(AliasSupport.ManipulateAliasIfValid(_aliasRegistry, _commandInput.Alias, _commandInput.Tokens.ToList(), AllTemplateShortNames)); } if (_commandInput.CheckForUpdates || _commandInput.CheckForUpdatesNoPrompt) { bool applyUpdates = _commandInput.CheckForUpdatesNoPrompt; CliTemplateUpdater updater = new CliTemplateUpdater(EnvironmentSettings, Installer, CommandName); bool updateCheckResult = await updater.CheckForUpdatesAsync(_settingsLoader.InstallUnitDescriptorCache.Descriptors.Values.ToList(), applyUpdates); return(updateCheckResult ? CreationResultStatus.Success : CreationResultStatus.CreateFailed); } if (_commandInput.SearchOnline) { return(await CliTemplateSearchCoordinator.SearchForTemplateMatchesAsync(EnvironmentSettings, _commandInput, _defaultLanguage).ConfigureAwait(false)); } if (string.IsNullOrWhiteSpace(TemplateName)) { return(EnterMaintenanceFlow()); } return(await EnterTemplateManipulationFlowAsync().ConfigureAwait(false)); } catch (TemplateAuthoringException tae) { Reporter.Error.WriteLine(tae.Message.Bold().Red()); return(CreationResultStatus.CreateFailed); } }