forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolateyGH-293) Upgrade all --except
- Loading branch information
1 parent
c30b3a1
commit 1b6821f
Showing
5 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/chocolatey.tests.integration/scenarios/UpgradeAllScenarios.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright © 2011 - Present RealDimensions Software, LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace chocolatey.tests.integration.scenarios | ||
{ | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using NuGet; | ||
using Should; | ||
using bdddoc.core; | ||
using chocolatey.infrastructure.app.commands; | ||
using chocolatey.infrastructure.app.configuration; | ||
using chocolatey.infrastructure.app.services; | ||
using chocolatey.infrastructure.results; | ||
|
||
public class UpgradeAllScenarios | ||
{ | ||
public abstract class ScenariosBase : TinySpec | ||
{ | ||
protected ConcurrentDictionary<string, PackageResult> Results; | ||
protected ChocolateyConfiguration Configuration; | ||
protected IChocolateyPackageService Service; | ||
|
||
public override void Context() | ||
{ | ||
Configuration = Scenario.upgrade(); | ||
Scenario.reset(Configuration); | ||
Configuration.PackageNames = Configuration.Input = "all"; | ||
Scenario.add_packages_to_source_location(Configuration, "upgradepackage*" + Constants.PackageExtension); | ||
Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension); | ||
Scenario.install_package(Configuration, "installpackage", "1.0.0"); | ||
Scenario.install_package(Configuration, "upgradepackage", "1.0.0"); | ||
Configuration.SkipPackageInstallProvider = true; | ||
|
||
Service = NUnitSetup.Container.GetInstance<IChocolateyPackageService>(); | ||
} | ||
} | ||
|
||
[Concern(typeof (ChocolateyUpgradeCommand))] | ||
public class when_upgrading_all_packages_happy_path : ScenariosBase | ||
{ | ||
public override void Because() | ||
{ | ||
Results = Service.upgrade_run(Configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_report_for_all_installed_packages() | ||
{ | ||
Results.Count().ShouldEqual(2); | ||
} | ||
|
||
[Fact] | ||
public void should_upgrade_packages_with_upgrades() | ||
{ | ||
var upgradePackageResult = Results.Where(x => x.Key == "upgradepackage").ToList(); | ||
upgradePackageResult.Count.ShouldEqual(1, "upgradepackage must be there once"); | ||
upgradePackageResult.First().Value.Version.ShouldEqual("1.1.0"); | ||
} | ||
|
||
[Fact] | ||
public void should_skip_packages_without_upgrades() | ||
{ | ||
var installPackageResult = Results.Where(x => x.Key == "installpackage").ToList(); | ||
installPackageResult.Count.ShouldEqual(1, "installpackage must be there once"); | ||
installPackageResult.First().Value.Version.ShouldEqual("1.0.0"); | ||
} | ||
} | ||
|
||
[Concern(typeof(ChocolateyUpgradeCommand))] | ||
public class when_upgrading_all_packages_with_except : ScenariosBase | ||
{ | ||
public override void Because() | ||
{ | ||
Configuration.UpgradeCommand.PackageNamesToSkip = "upgradepackage"; | ||
Results = Service.upgrade_run(Configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_report_for_all_non_skipped_packages() | ||
{ | ||
Results.Count().ShouldEqual(1); | ||
} | ||
|
||
[Fact] | ||
public void should_skip_packages_in_except_list() | ||
{ | ||
var upgradePackageResult = Results.Where(x => x.Key == "upgradepackage").ToList(); | ||
upgradePackageResult.Count.ShouldEqual(0, "upgradepackage should not be in the results list"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters