Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (maint) formatting
  (chocolateyGH-305) Create log location
  • Loading branch information
ferventcoder committed Jun 4, 2015
2 parents 55d3f94 + 5601e2d commit e5d9a37
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace chocolatey.tests.infrastructure.app.services
using System.Linq;
using Moq;
using NuGet;
using Should;
using chocolatey.infrastructure.adapters;
using chocolatey.infrastructure.app;
using chocolatey.infrastructure.app.configuration;
Expand Down Expand Up @@ -192,8 +191,8 @@ 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()
Expand All @@ -202,12 +201,12 @@ public override void Context()
fileSystem.ResetCalls();
registryKeys.Clear();
registryKeys.Add(new RegistryApplicationKey
{
InstallLocation = string.Empty,
UninstallString = originalUninstallString,
HasQuietUninstall = true,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat"
});
{
InstallLocation = string.Empty,
UninstallString = originalUninstallString,
HasQuietUninstall = true,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat"
});
packageInformation.RegistrySnapshot = new Registry("123", registryKeys);
}

Expand Down Expand Up @@ -304,27 +303,25 @@ public void should_call_command_executor()
{
commandExecutor.Verify(c => c.execute(expectedUninstallString, installerType.build_uninstall_command_arguments().trim_safe(), It.IsAny<int>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<Action<object, DataReceivedEventArgs>>(), It.IsAny<bool>()), Times.Once);
}
}
}

public class when_AutomaticUninstallerService_cannot_determine_silent_install_arguments : AutomaticUninstallerServiceSpecsBase
{

public override void Context()
{
base.Context();
registryKeys.Clear();
commandExecutor.ResetCalls();
registryKeys.Add(new RegistryApplicationKey
{
InstallLocation = @"C:\Program Files (x86)\WinDirStat",
UninstallString = "{0} {1}".format_with(originalUninstallString, "/bob"),
HasQuietUninstall = false,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat",
InstallerType = InstallerType.Unknown,
});
{
InstallLocation = @"C:\Program Files (x86)\WinDirStat",
UninstallString = "{0} {1}".format_with(originalUninstallString, "/bob"),
HasQuietUninstall = false,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat",
InstallerType = InstallerType.Unknown,
});
packageInformation.RegistrySnapshot = new Registry("123", registryKeys);
fileSystem.Setup(x => x.combine_paths(config.CacheLocation, It.IsAny<string>(), It.IsAny<string>())).Returns("");

fileSystem.Setup(x => x.combine_paths(config.CacheLocation, "chocolatey", It.IsAny<string>(), It.IsAny<string>())).Returns("");
}

// under normal circumstances, it prompts so the user can decide, but if -y is passed it will skip
Expand All @@ -339,14 +336,14 @@ public void should_log_why_it_skips_auto_uninstaller()
{
MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - Installer type was not detected and no silent uninstall key exists."), Times.Once);
}

[Fact]
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_AutomaticUninstallerService_defines_uninstall_switches : AutomaticUninstallerServiceSpecsBase
{
private Action because;
Expand All @@ -369,16 +366,16 @@ private void test_installertype(IInstaller installer, bool hasQuietUninstallStri
{
reset();
registryKeys.Add(new RegistryApplicationKey
{
InstallLocation = @"C:\Program Files (x86)\WinDirStat",
UninstallString = "{0} {1}".format_with(originalUninstallString, registryUninstallArgs),
HasQuietUninstall = hasQuietUninstallString,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat",
InstallerType = installer.InstallerType,
});
{
InstallLocation = @"C:\Program Files (x86)\WinDirStat",
UninstallString = "{0} {1}".format_with(originalUninstallString, registryUninstallArgs),
HasQuietUninstall = hasQuietUninstallString,
KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat",
InstallerType = installer.InstallerType,
});
packageInformation.RegistrySnapshot = new Registry("123", registryKeys);
fileSystem.Setup(x => x.combine_paths(config.CacheLocation, It.IsAny<string>(), It.IsAny<string>())).Returns(logLocation);
fileSystem.Setup(x => x.combine_paths(config.CacheLocation, "chocolatey", It.IsAny<string>(), It.IsAny<string>())).Returns(logLocation);

because();

var installerTypeArgs = installer.build_uninstall_command_arguments().trim_safe().Replace(InstallTokens.PACKAGE_LOCATION, logLocation);
Expand All @@ -393,60 +390,60 @@ private void test_installertype(IInstaller installer, bool hasQuietUninstallStri
//{
// test_installertype(new CustomInstaller(), hasQuietUninstallString: false);
//}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_unknown_and_has_quiet_uninstall_is_true()
{
test_installertype(new CustomInstaller(), hasQuietUninstallString: true);
}
}

[Fact]
public void should_use_MsiInstaller_uninstall_args_when_installtype_is_msi_and_has_quiet_uninstall_is_false()
{
test_installertype(new MsiInstaller(), hasQuietUninstallString: false);
}
}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_msi_and_has_quiet_uninstall_is_true()
{
test_installertype(new MsiInstaller(), hasQuietUninstallString: true);
}
}

[Fact]
public void should_use_InnoSetupInstaller_uninstall_args_when_installtype_is_innosetup_and_has_quiet_uninstall_is_false()
{
test_installertype(new InnoSetupInstaller(), hasQuietUninstallString: false);
}
}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_innosetup_and_has_quiet_uninstall_is_true()
{
test_installertype(new InnoSetupInstaller(), hasQuietUninstallString: true);
}
}

[Fact]
public void should_use_InstallShieldInstaller_uninstall_args_when_installtype_is_installshield_and_has_quiet_uninstall_is_false()
{
test_installertype(new InstallShieldInstaller(), hasQuietUninstallString: false);
}
}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_installshield_and_has_quiet_uninstall_is_true()
{
test_installertype(new InstallShieldInstaller(), hasQuietUninstallString: true);
}
}

[Fact]
public void should_use_NsisInstaller_uninstall_args_when_installtype_is_nsis_and_has_quiet_uninstall_is_false()
{
test_installertype(new NsisInstaller(), hasQuietUninstallString: false);
}
}

[Fact]
public void should_use_registry_uninstall_args_when_installtype_is_nsis_and_has_quiet_uninstall_is_true()
{
test_installertype(new NsisInstaller(), hasQuietUninstallString: true);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
{
//todo: ultimately we should merge keys
uninstallArgs += " " + installer.build_uninstall_command_arguments();
var logLocation = _fileSystem.combine_paths(config.CacheLocation, pkgInfo.Package.Id, pkgInfo.Package.Version.to_string());
var logLocation = _fileSystem.combine_paths(config.CacheLocation, "chocolatey", pkgInfo.Package.Id, pkgInfo.Package.Version.to_string());
_fileSystem.create_directory_if_not_exists(_fileSystem.get_directory_name(logLocation));

uninstallArgs = uninstallArgs.Replace(InstallTokens.PACKAGE_LOCATION, logLocation);
}

Expand Down

0 comments on commit e5d9a37

Please sign in to comment.