Skip to content

Commit

Permalink
(GH-255) Uninstaller should not depend on InstallLocation
Browse files Browse the repository at this point in the history
InstallLocation is not always filled out in the registry because it is
not required, so only check the value if it is not empty.
  • Loading branch information
ferventcoder committed Apr 22, 2015
1 parent fd1936e commit da1f2cb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,42 @@ public void should_not_call_command_executor()
{
commandExecutor.Verify(c => c.execute(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Never);
}
}

public class when_install_location_is_empty : AutomaticUninstallerServiceSpecsBase
{
public override void Context()
{
base.Context();
fileSystem.ResetCalls();
registryKeys.Clear();
registryKeys.Add(new RegistryApplicationKey
{
InstallLocation = string.Empty,
UninstallString = originalUninstallString,
HasQuietUninstall = false,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat"
});
packageInformation.RegistrySnapshot = new Registry("123", registryKeys);
}

public override void Because()
{
service.run(packageResult, config);
}

[Fact]
public void should_call_get_package_information()
{
packageInfoService.Verify(s => s.get_package_information(It.IsAny<IPackage>()), Times.Once);
}

[Fact]
public void should_call_command_executor()
{
var args = installerType.build_uninstall_command_arguments().trim_safe();
commandExecutor.Verify(c => c.execute(expectedUninstallString, args, It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Once);
}
}

public class when_registry_location_does_not_exist : AutomaticUninstallerServiceSpecsBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
{
this.Log().Debug(() => " Preparing uninstall key '{0}'".format_with(key.UninstallString));

if (!_fileSystem.directory_exists(key.InstallLocation) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation))
if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation))
{
this.Log().Info(" Skipping auto uninstaller - The application appears to have been uninstalled already by other means.");
this.Log().Debug(() => " Searched for install path '{0}' - found? {1}".format_with(key.InstallLocation.escape_curly_braces(), _fileSystem.directory_exists(key.InstallLocation)));
Expand Down

0 comments on commit da1f2cb

Please sign in to comment.