Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (specs) Fix scenario for failed uninstall
  (maint) formatting
  • Loading branch information
ferventcoder committed Jun 7, 2015
2 parents 012b118 + ade667e commit 2f93efe
Showing 1 changed file with 45 additions and 38 deletions.
83 changes: 45 additions & 38 deletions src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override void Context()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_noop_uninstalling_a_package : ScenariosBase
{
public override void Context()
Expand Down Expand Up @@ -104,7 +104,7 @@ public void should_contain_a_message_that_it_would_have_run_a_powershell_script(
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_noop_uninstalling_a_package_that_does_not_exist : ScenariosBase
{
public override void Context()
Expand Down Expand Up @@ -132,7 +132,7 @@ public void should_contain_a_message_that_it_was_unable_to_find_package()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_happy_path : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -174,15 +174,15 @@ public void should_delete_a_shim_for_graphical_in_the_bin_directory()

File.Exists(shimfile).ShouldBeFalse();
}

[Fact]
public void should_delete_any_files_created_during_the_install()
{
var generatedFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames,"simplefile.txt");
var generatedFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "simplefile.txt");

File.Exists(generatedFile).ShouldBeFalse();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -220,7 +220,7 @@ public void config_should_match_package_result_name()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_force_uninstalling_a_package : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -268,7 +268,7 @@ public void should_delete_a_shim_for_graphical_in_the_bin_directory()

File.Exists(shimfile).ShouldBeFalse();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -306,7 +306,7 @@ public void config_should_match_package_result_name()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_packages_with_packages_config : ScenariosBase
{
public override void Context()
Expand All @@ -321,14 +321,14 @@ public override void Because()
}

[Fact]
[ExpectedException(typeof(ApplicationException))]
[ExpectedException(typeof (ApplicationException))]
public void should_throw_an_error_that_it_is_not_allowed()
{
Results = Service.uninstall_run(Configuration);
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_with_a_read_and_delete_share_locked_file : ScenariosBase
{
private PackageResult _packageResult;
Expand Down Expand Up @@ -381,7 +381,7 @@ public void should_contain_a_message_that_it_uninstalled_successfully()

expectedMessage.ShouldBeTrue();
}

[Fact]
public void should_have_a_successful_package_result()
{
Expand All @@ -401,7 +401,7 @@ public void should_not_have_warning_package_result()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_with_an_exclusively_locked_file : ScenariosBase
{
private PackageResult _packageResult;
Expand All @@ -426,7 +426,7 @@ public override void Because()
Results = Service.uninstall_run(Configuration);
_packageResult = Results.FirstOrDefault().Value;
}

[Fact]
public void should_not_be_able_to_remove_the_package_from_the_lib_directory()
{
Expand Down Expand Up @@ -482,16 +482,16 @@ public void should_not_have_warning_package_result()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_with_added_files : ScenariosBase
{
private PackageResult packageResult;

public override void Context()
{
base.Context();
var fileAdded = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames,"dude.txt");
File.WriteAllText(fileAdded,"hellow");
var fileAdded = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "dude.txt");
File.WriteAllText(fileAdded, "hellow");
}

public override void Because()
Expand All @@ -507,15 +507,15 @@ public void should_keep_the_added_file()

File.Exists(fileAdded).ShouldBeTrue();
}

[Fact]
public void should_delete_everything_but_the_added_file_from_the_package_directory()
{
var files = Directory.GetFiles(Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames));

foreach (var file in files.or_empty_list_if_null())
{
Path.GetFileName(file).ShouldEqual("dude.txt","Expected files were not deleted.");
Path.GetFileName(file).ShouldEqual("dude.txt", "Expected files were not deleted.");
}
}

Expand All @@ -542,7 +542,7 @@ public void should_delete_a_shim_for_graphical_in_the_bin_directory()

File.Exists(shimfile).ShouldBeFalse();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -580,16 +580,16 @@ public void config_should_match_package_result_name()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_with_changed_files : ScenariosBase
{
private PackageResult packageResult;

public override void Context()
{
base.Context();
var fileChanged = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames,"tools","chocolateyInstall.ps1");
File.WriteAllText(fileChanged,"hellow");
var fileChanged = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "chocolateyInstall.ps1");
File.WriteAllText(fileChanged, "hellow");
}

public override void Because()
Expand All @@ -605,7 +605,7 @@ public void should_keep_the_changed_file()

File.Exists(fileChanged).ShouldBeTrue();
}

[Fact]
public void should_delete_everything_but_the_changed_file_from_the_package_directory()
{
Expand Down Expand Up @@ -640,7 +640,7 @@ public void should_delete_a_shim_for_graphical_in_the_bin_directory()

File.Exists(shimfile).ShouldBeFalse();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -678,16 +678,16 @@ public void config_should_match_package_result_name()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_force_uninstalling_a_package_with_added_and_changed_files : ScenariosBase
{
private PackageResult packageResult;

public override void Context()
{
base.Context();
var fileChanged = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames,"tools","chocolateyInstall.ps1");
File.WriteAllText(fileChanged,"hellow");
var fileChanged = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "chocolateyInstall.ps1");
File.WriteAllText(fileChanged, "hellow");
var fileAdded = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "dude.txt");
File.WriteAllText(fileAdded, "hellow");
Configuration.Force = true;
Expand All @@ -714,15 +714,15 @@ public void should_not_keep_the_added_file()

File.Exists(fileChanged).ShouldBeFalse();
}

[Fact]
public void should_not_keep_the_changed_file()
{
var fileChanged = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "chocolateyInstall.ps1");

File.Exists(fileChanged).ShouldBeFalse();
}

[Fact]
public void should_delete_the_rollback()
{
Expand All @@ -746,7 +746,7 @@ public void should_delete_a_shim_for_graphical_in_the_bin_directory()

File.Exists(shimfile).ShouldBeFalse();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -784,7 +784,7 @@ public void config_should_match_package_result_name()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_that_does_not_exist : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -812,7 +812,7 @@ public void should_contain_a_message_that_it_was_unable_to_find_package()

expectedMessage.ShouldBeTrue();
}

[Fact]
public void should_contain_a_warning_message_that_it_uninstalled_successfully()
{
Expand Down Expand Up @@ -859,29 +859,36 @@ public void should_have_an_error_package_result()
}
}

[Concern(typeof(ChocolateyUninstallCommand))]
[Concern(typeof (ChocolateyUninstallCommand))]
public class when_uninstalling_a_package_that_errors : ScenariosBase
{
private PackageResult packageResult;

public override void Context()
{
{
base.Context();
Configuration.PackageNames = Configuration.Input = "badpackage";
}

public override void Because()
{
Results = Service.uninstall_run(Configuration);
Results = Service.uninstall_run(Configuration);
packageResult = Results.FirstOrDefault().Value;
}

[Fact]
public void should_remove_package_from_the_lib_directory()
public void should_not_remove_package_from_the_lib_directory()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames);

Directory.Exists(packageDir).ShouldBeFalse();
Directory.Exists(packageDir).ShouldBeTrue();
}

[Fact]
public void should_still_have_the_package_file_in_the_directory()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
File.Exists(packageFile).ShouldBeTrue();
}

[Fact]
Expand Down

0 comments on commit 2f93efe

Please sign in to comment.