Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-14) alternative sources #40

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cf2f665
(GH-14) Define ISourceRunner
ferventcoder May 21, 2015
83c4b62
(GH-14) Add SourceType to config
ferventcoder May 21, 2015
0e9b376
(refactor) CommandExecutor instance method
ferventcoder May 21, 2015
6af746f
(maint) removing commented code
ferventcoder May 21, 2015
5311ce0
(GH-14) INugetService implements ISourceRunner
ferventcoder May 21, 2015
0f12556
(GH-14) Web Platform Installer source
ferventcoder May 21, 2015
e2c0a59
(GH-14) Container registration
ferventcoder May 21, 2015
45166b2
(GH-14) ChocolateyPackageService implement source runners
ferventcoder May 21, 2015
6017299
(GH-14) ensure_source_app - called by commands
ferventcoder May 21, 2015
b02e414
(GH-14) Uninstall adds source
ferventcoder May 21, 2015
dd2afd2
(refactor) naming
ferventcoder May 21, 2015
3661276
(GH-14)(refactor) move consts to WebPiService
ferventcoder May 21, 2015
6fce571
(GH-14) Ruby Gems source
ferventcoder May 21, 2015
95b4b90
(refactor) naming/comments
ferventcoder May 26, 2015
e9b4fb2
(GH-14) Windows Features Source
ferventcoder May 26, 2015
413da2b
(doc) WindowsFeatures - more links
ferventcoder Jun 2, 2015
7ae1939
(maint) formatting
ferventcoder Jun 2, 2015
10b4f8c
(GH-14) rename registry exists to installer keys
ferventcoder Jun 2, 2015
58d0a39
(GH-14) attempt exec minimized
ferventcoder Jun 3, 2015
f489545
(refactor) IFileSystem.get_current_assembly_path
ferventcoder Jun 3, 2015
4bb5d92
(GH-14) use case insensitive dictionaries
ferventcoder Jun 3, 2015
31e3f9c
(doc) add returns statement
ferventcoder Jun 3, 2015
0f6bc80
(GH-14) Find path to executable
ferventcoder Jun 3, 2015
b09644e
(maint) formatting
ferventcoder Jun 3, 2015
00d35b1
(GH-14) RegistryService.get_key()
ferventcoder Jun 3, 2015
c133229
(GH-14) Cygwin Alternate source
ferventcoder Jun 3, 2015
66e98ea
(maint) add registry service evaluation
ferventcoder Jun 4, 2015
60c99cb
(GH-14) use the packagenames separator
ferventcoder Jun 4, 2015
45ed065
(GH-14) Python Alternate Source
ferventcoder Jun 4, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static void remove_old_chocolatey_exe(IFileSystem fileSystem)
{
try
{
fileSystem.delete_file(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty) + ".old");
fileSystem.delete_file(fileSystem.get_current_assembly_path() + ".old");
fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old"));
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey.tests.integration/NUnitSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static void fix_application_parameter_variables(Container container)
{
var fileSystem = container.GetInstance<IFileSystem>();

var applicationLocation = fileSystem.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty));
var applicationLocation = fileSystem.get_directory_name(fileSystem.get_current_assembly_path());

var field = typeof (ApplicationParameters).GetField("InstallLocation");
field.SetValue(null, applicationLocation);
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey.tests.integration/Scenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Scenario

public static string get_top_level()
{
return _fileSystem.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty));
return _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path());
}

public static string get_package_install_path()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void Context()

public override void Because()
{
result = CommandExecutor.execute("cmd.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, fileSystem.get_current_directory(), null, (s, e) => { errorOutput += e.Data; }, updateProcessPath: false);
result = commandExecutor.execute("cmd.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, fileSystem.get_current_directory(), null, (s, e) => { errorOutput += e.Data; }, updateProcessPath: false);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override void Context()
{
FileSystem = new DotNetFileSystem();
Provider = new CrytpoHashProvider(FileSystem,CryptoHashProviderType.Md5);
ContextDirectory = FileSystem.combine_paths(FileSystem.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty)), "context");
ContextDirectory = FileSystem.combine_paths(FileSystem.get_directory_name(FileSystem.get_current_assembly_path()), "context");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace chocolatey.tests.integration.infrastructure.filesystem
using NUnit.Framework;
using Should;
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.platforms;

public class DotNetFileSystemSpecs
{
Expand Down Expand Up @@ -48,6 +49,53 @@ public override void Context()
}
}

[Category("Integration")]
public class when_finding_paths_to_executables_with_dotNetFileSystem : DotNetFileSystemSpecsBase
{
public override void Because()
{
}

[Fact]
public void GetExecutablePath_should_find_existing_executable()
{
FileSystem.get_executable_path("cmd").ShouldEqual(
Platform.get_platform() == PlatformType.Windows ?
"C:\\Windows\\system32\\cmd.exe"
: "cmd"
);
}

[Fact]
public void GetExecutablePath_should_find_existing_executable_with_extension()
{
FileSystem.get_executable_path("cmd.exe").ShouldEqual(
Platform.get_platform() == PlatformType.Windows ?
"C:\\Windows\\system32\\cmd.exe"
: "cmd"
);
}

[Fact]
public void GetExecutablePath_should_return_same_value_when_executable_is_not_found()
{
FileSystem.get_executable_path("daslakjsfdasdfwea").ShouldEqual("daslakjsfdasdfwea");
}

[Fact]
public void GetExecutablePath_should_return_empty_string_when_value_is_null()
{
FileSystem.get_executable_path(null).ShouldEqual(string.Empty);
}

[Fact]
public void GetExecutablePath_should_return_empty_string_when_value_is_empty_string()
{
FileSystem.get_executable_path(string.Empty).ShouldEqual(string.Empty);
}

}

[Category("Integration")]
public class when_doing_file_system_operations_with_dotNetFileSystem : DotNetFileSystemSpecsBase
{
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="infrastructure.app\services\AutomaticUninstallerServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\FilesServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\NugetServiceSpecs.cs" />
<Compile Include="infrastructure.app\services\RegistryServiceSpecs.cs" />
<Compile Include="infrastructure\commands\ExternalCommandArgsBuilderSpecs.cs" />
<Compile Include="infrastructure\commandline\InteractivePromptSpecs.cs" />
<Compile Include="infrastructure\commands\CommandExecutorSpecs.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override void Context()
packageResults.GetOrAdd("regular", packageResult);

fileSystem.Setup(f => f.directory_exists(registryKeys.FirstOrDefault().InstallLocation)).Returns(true);
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(true);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(true);
fileSystem.Setup(f => f.get_full_path(expectedUninstallString)).Returns(expectedUninstallString);
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public override void Context()
{
base.Context();
registryService.ResetCalls();
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
}

public override void Because()
Expand Down Expand Up @@ -264,7 +264,7 @@ public override void Context()
fileSystem.ResetCalls();
fileSystem.Setup(f => f.directory_exists(registryKeys.FirstOrDefault().InstallLocation)).Returns(false);
registryService.ResetCalls();
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
}

public override void Because()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// 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.services
{
using System;
using Microsoft.Win32;
using Moq;
using Should;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.services;
using Registry = chocolatey.infrastructure.app.domain.Registry;

public class RegistryServiceSpecs
{
public abstract class RegistryServiceSpecsBase : TinySpec
{
protected RegistryService Service;
protected Mock<IFileSystem> FileSystem = new Mock<IFileSystem>();
protected Mock<IXmlService> XmlService = new Mock<IXmlService>();

public override void Context()
{
reset();
Service = new RegistryService(XmlService.Object, FileSystem.Object);
}

protected void reset()
{
FileSystem.ResetCalls();
XmlService.ResetCalls();
MockLogger.reset();
}
}



public class when_RegistryService_get_installer_keys_is_called : RegistryServiceSpecsBase
{
private Registry _result;

public override void Context()
{
base.Context();
}

public override void Because()
{
_result = Service.get_installer_keys();
}


[Fact]
public void should_not_be_null()
{
_result.ShouldNotBeNull();
}

}

public class when_RegistryService_get_key_is_called_for_a_value_that_exists : RegistryServiceSpecsBase
{
//todo does any of this test correctly on *nix?

private RegistryKey _result;
private RegistryHive _hive = RegistryHive.CurrentUser;
private string _subkeyPath = "Console";

public override void Context()
{
base.Context();
}

public override void Because()
{
_result = Service.get_key(_hive, _subkeyPath);
}

[Fact]
public void should_return_a_non_null_value()
{
_result.ShouldNotBeNull();
}

[Fact]
public void should_return_a_value_of_type_RegistryKey()
{
_result.ShouldBeType<RegistryKey>();
}

[Fact]
public void should_contain_keys()
{
_result.GetSubKeyNames().ShouldNotBeEmpty();
}

[Fact]
public void should_contain_values()
{
_result.GetValueNames().ShouldNotBeEmpty();
}
}

public class when_RegistryService_get_key_is_called_for_a_value_that_does_not_exist : RegistryServiceSpecsBase
{
//todo does any of this test correctly on *nix?

private RegistryKey _result;
private RegistryHive _hive = RegistryHive.CurrentUser;
private string _subkeyPath = "Software\\alsdjfalskjfaasdfasdf";

public override void Context()
{
base.Context();
}

public override void Because()
{
_result = Service.get_key(_hive, _subkeyPath);
}

[Fact]
public void should_not_error()
{
//nothing to see here
}

[Fact]
public void should_return_null_key()
{
_result.ShouldBeNull();
}
}

//todo a subkey that exists only in 32 bit mode (must create it to test it though)
}
}
Loading