forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stable: (chocolateyGH-501) allow shutting off sign when no network (chocolateyGH-448) Add Output Directory for choco new (maint) assume xml file is utf8 (maint) formatting (chocolateyGH-258) Switch for only using silent args provided (chocolateyGH-682) Add summary log file (chocolateyGH-644) Add info command (chocolateyGH-646) Add detail/detailed for search/list (maint) template share location should be appropriate (build) add a run.codesign switch
- Loading branch information
Showing
22 changed files
with
715 additions
and
29 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
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
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
215 changes: 215 additions & 0 deletions
215
src/chocolatey.tests/infrastructure.app/commands/ChocolateyInfoCommandSpecs.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,215 @@ | ||
// 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.infrastructure.app.commands | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using chocolatey.infrastructure.app.attributes; | ||
using chocolatey.infrastructure.app.commands; | ||
using chocolatey.infrastructure.app.configuration; | ||
using chocolatey.infrastructure.app.services; | ||
using chocolatey.infrastructure.commandline; | ||
using Moq; | ||
using Should; | ||
|
||
public class ChocolateyInfoCommandSpecs | ||
{ | ||
public abstract class ChocolateyInfoCommandSpecsBase : TinySpec | ||
{ | ||
protected ChocolateyInfoCommand command; | ||
protected Mock<IChocolateyPackageService> packageService = new Mock<IChocolateyPackageService>(); | ||
protected ChocolateyConfiguration configuration = new ChocolateyConfiguration(); | ||
|
||
public override void Context() | ||
{ | ||
configuration.Sources = "bob"; | ||
command = new ChocolateyInfoCommand(packageService.Object); | ||
} | ||
} | ||
|
||
public class when_implementing_command_for : ChocolateyInfoCommandSpecsBase | ||
{ | ||
private List<string> results; | ||
|
||
public override void Because() | ||
{ | ||
results = command.GetType().GetCustomAttributes(typeof(CommandForAttribute), false).Cast<CommandForAttribute>().Select(a => a.CommandName).ToList(); | ||
} | ||
|
||
[Fact] | ||
public void should_implement_info() | ||
{ | ||
results.ShouldContain("info"); | ||
} | ||
} | ||
|
||
public class when_configurating_the_argument_parser : ChocolateyInfoCommandSpecsBase | ||
{ | ||
private OptionSet optionSet; | ||
|
||
public override void Context() | ||
{ | ||
base.Context(); | ||
optionSet = new OptionSet(); | ||
} | ||
|
||
public override void Because() | ||
{ | ||
command.configure_argument_parser(optionSet, configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_add_source_to_the_option_set() | ||
{ | ||
optionSet.Contains("source").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_short_version_of_source_to_the_option_set() | ||
{ | ||
optionSet.Contains("s").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_localonly_to_the_option_set() | ||
{ | ||
optionSet.Contains("localonly").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_short_version_of_localonly_to_the_option_set() | ||
{ | ||
optionSet.Contains("l").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_prerelease_to_the_option_set() | ||
{ | ||
optionSet.Contains("prerelease").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_short_version_of_prerelease_to_the_option_set() | ||
{ | ||
optionSet.Contains("pre").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_user_to_the_option_set() | ||
{ | ||
optionSet.Contains("user").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_short_version_of_user_to_the_option_set() | ||
{ | ||
optionSet.Contains("u").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_password_to_the_option_set() | ||
{ | ||
optionSet.Contains("password").ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_add_short_version_of_password_to_the_option_set() | ||
{ | ||
optionSet.Contains("p").ShouldBeTrue(); | ||
} | ||
} | ||
|
||
public class when_handling_additional_argument_parsing : ChocolateyInfoCommandSpecsBase | ||
{ | ||
private readonly IList<string> unparsedArgs = new List<string>(); | ||
private string source = "https://somewhereoutthere"; | ||
private Action because; | ||
|
||
public override void Context() | ||
{ | ||
base.Context(); | ||
unparsedArgs.Add("pkg1"); | ||
unparsedArgs.Add("pkg2"); | ||
configuration.Sources = source; | ||
} | ||
|
||
public override void Because() | ||
{ | ||
because = () => command.handle_additional_argument_parsing(unparsedArgs, configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_set_unparsed_arguments_to_configuration_input() | ||
{ | ||
because(); | ||
configuration.Input.ShouldEqual("pkg1 pkg2"); | ||
} | ||
|
||
[Fact] | ||
public void should_leave_source_as_set() | ||
{ | ||
configuration.ListCommand.LocalOnly = false; | ||
because(); | ||
configuration.Sources.ShouldEqual(source); | ||
} | ||
|
||
[Fact] | ||
public void should_set_exact_to_true() | ||
{ | ||
configuration.ListCommand.Exact = false; | ||
because(); | ||
configuration.ListCommand.Exact.ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void should_set_verbose_to_true() | ||
{ | ||
configuration.Verbose = false; | ||
because(); | ||
configuration.Verbose.ShouldBeTrue(); | ||
} | ||
} | ||
|
||
public class when_noop_is_called : ChocolateyInfoCommandSpecsBase | ||
{ | ||
public override void Because() | ||
{ | ||
command.noop(configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_call_service_list_noop() | ||
{ | ||
packageService.Verify(c => c.list_noop(configuration), Times.Once); | ||
} | ||
} | ||
|
||
public class when_run_is_called : ChocolateyInfoCommandSpecsBase | ||
{ | ||
public override void Because() | ||
{ | ||
command.run(configuration); | ||
} | ||
|
||
[Fact] | ||
public void should_call_service_list_run() | ||
{ | ||
packageService.Verify(c => c.list_run(configuration), Times.Once); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.