Skip to content

Commit

Permalink
Finishing cross platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed Aug 19, 2017
1 parent fc4a4a3 commit 370fa70
Show file tree
Hide file tree
Showing 27 changed files with 123 additions and 86 deletions.
Binary file modified .nuget/NuGet.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion Build/Publish-StandaloneCore-Releases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ $StandaloneCoreReleases = @('PactNet-Windows','PactNet-OSX','PactNet-Linux-x64',
foreach ($StandaloneCoreRelease in $StandaloneCoreReleases)
{
# Build the NuGet package
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "Build\$StandaloneCoreRelease.nuspec"
$ReleaseSource = $StandaloneCoreRelease.Replace('PactNet-', '').ToLower()
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "Build\$ReleaseSource\$StandaloneCoreRelease.nuspec"
& $NuGetExe pack $ProjectPath -Properties Configuration=Release -OutputDirectory $BuildRoot -Version $ReleaseVersionNumber -NoPackageAnalysis -NoDefaultExcludes
if (-not $?)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<licenseUrl>https://github.com/SEEK-Jobs/pact-net/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/SEEK-Jobs/pact-net</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A .NET version of Pact, which enables consumer driven contract testing.</description>
<description>A .NET version of Pact, which enables consumer driven contract testing. This package contains the 64-bit Linux specific core engine.</description>
<dependencies>
<dependency id="PactNet" version="$version$" />
</dependencies>
</metadata>
<files>
<file src="tools\pact-linux-x86_64\**" target="tools\pact-linux-x86_64\" />
<file src="PactNet.targets" target="build" />
<file src="..\tools\pact-linux-x86_64\**" target="tools\pact-linux-x86_64\" />
<file src="config.json" target="tools\pact-linux-x86_64\config.json" />
<file src="..\PactNet.targets" target="build" />
</files>
</package>
3 changes: 3 additions & 0 deletions Build/linux-x64/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"fileName": "{pactCoreDir}/bin/{script}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<licenseUrl>https://github.com/SEEK-Jobs/pact-net/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/SEEK-Jobs/pact-net</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A .NET version of Pact, which enables consumer driven contract testing.</description>
<description>A .NET version of Pact, which enables consumer driven contract testing. This package contains the 32-bit Linux specific core engine.</description>
<dependencies>
<dependency id="PactNet" version="$version$" />
</dependencies>
</metadata>
<files>
<file src="tools\pact-linux-x86\**" target="tools\pact-linux-x86\" />
<file src="PactNet.targets" target="build" />
<file src="..\tools\pact-linux-x86\**" target="tools\pact-linux-x86\" />
<file src="config.json" target="tools\pact-linux-x86\config.json" />
<file src="..\PactNet.targets" target="build" />
</files>
</package>
3 changes: 3 additions & 0 deletions Build/linux-x86/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"fileName": "{pactCoreDir}/bin/{script}"
}
7 changes: 4 additions & 3 deletions Build/PactNet-OSX.nuspec → Build/osx/PactNet-OSX.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<licenseUrl>https://github.com/SEEK-Jobs/pact-net/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/SEEK-Jobs/pact-net</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A .NET version of Pact, which enables consumer driven contract testing.</description>
<description>A .NET version of Pact, which enables consumer driven contract testing. This package contains the Mac OSX specific core engine.</description>
<dependencies>
<dependency id="PactNet" version="$version$" />
</dependencies>
</metadata>
<files>
<file src="tools\pact-osx\**" target="tools\pact-osx\" />
<file src="PactNet.targets" target="build" />
<file src="..\tools\pact-osx\**" target="tools\pact-osx\" />
<file src="config.json" target="tools\pact-osx\config.json" />
<file src="..\PactNet.targets" target="build" />
</files>
</package>
3 changes: 3 additions & 0 deletions Build/osx/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"fileName": "{pactCoreDir}/bin/{script}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<licenseUrl>https://github.com/SEEK-Jobs/pact-net/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/SEEK-Jobs/pact-net</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A .NET version of Pact, which enables consumer driven contract testing.</description>
<description>A .NET version of Pact, which enables consumer driven contract testing. This package contains the Windows specific core engine.</description>
<dependencies>
<dependency id="PactNet" version="$version$" />
</dependencies>
</metadata>
<files>
<file src="tools\pact-win32\**" target="tools\pact-win32\" />
<file src="PactNet.targets" target="build\PactNet-Windows.targets" />
<file src="..\tools\pact-win32\**" target="tools\pact-win32\" />
<file src="config.json" target="tools\pact-win32\config.json" />
<file src="..\PactNet.targets" target="build\PactNet-Windows.targets" />
</files>
</package>
11 changes: 11 additions & 0 deletions Build/windows/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"fileName": "{pactCoreDir}\\lib\\ruby\\bin.real\\ruby.exe",
"arguments": "-rbundler/setup -I\"{pactCoreDir}\\lib\\app\\lib\" \"{pactCoreDir}\\lib\\app\\{script}.rb\"",
"environment": {
"ROOT_PATH": "{pactCoreDir}",
"RUNNING_PATH": "{pactCoreDir}\\bin\\",
"BUNDLE_GEMFILE": "{pactCoreDir}\\lib\\vendor\\Gemfile",
"RUBYLIB": "{pactCoreDir}\\lib\\ruby\\lib\\ruby\\site_ruby\\2.2.0;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\site_ruby\\2.2.0\\i386-mingw32;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\site_ruby;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\vendor_ruby\\2.2.0;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\vendor_ruby\\2.2.0\\i386-mingw32;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\vendor_ruby;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\2.2.0;{pactCoreDir}\\lib\\ruby\\lib\\ruby\\2.2.0\\i386-mingw32",
"SSL_CERT_FILE": "{pactCoreDir}\\lib\\ruby\\lib\\ca-bundle.crt"
}
}
2 changes: 1 addition & 1 deletion PactNet.Tests/Core/MockProviderHostConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Ctor_WhenCalled_SetsTheCorrectScript()
{
var config = GetSubject();

Assert.Equal("pact-mock-service.rb", config.Script);
Assert.Equal("pact-mock-service", config.Script);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions PactNet.Tests/Core/PactCoreHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private IPactCoreHost GetSubject(string script)
[Fact]
public void Start_WhenStdOutIsWrittendTo_LinesAreWrittenToTheOutputters()
{
var pactCoreHost = GetSubject("write-to-stdout.rb");
var pactCoreHost = GetSubject("write-to-stdout");

pactCoreHost.Start();

Expand All @@ -56,7 +56,7 @@ public void Start_WhenStdOutIsWrittendTo_LinesAreWrittenToTheOutputters()
[Fact]
public void Start_WhenStdErrIsWrittendTo_LinesAreWrittenToTheOutputters()
{
var pactCoreHost = GetSubject("write-to-stderr.rb");
var pactCoreHost = GetSubject("write-to-stderr");

pactCoreHost.Start();

Expand Down
10 changes: 6 additions & 4 deletions PactNet.Tests/Core/PactVerifierHostConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Ctor_WhenCalled_SetsTheCorrectScript()
{
var config = GetSubject();

Assert.Equal("pact-provider-verifier.rb", config.Script);
Assert.Equal("pact-provider-verifier", config.Script);
}

[Fact]
Expand Down Expand Up @@ -104,9 +104,11 @@ public void Ctor_WhenCalledWithPublishVerificationResults_SetsTheCorrectArgs()
var pactUri = "./tester-pact/pact-file.json";
var providerStateSetupUri = new Uri("http://127.0.0.1/states/");

var verifierConfig = new PactVerifierConfig();
verifierConfig.PublishVerificationResults = true;
verifierConfig.ProviderVersion = "1.0.0";
var verifierConfig = new PactVerifierConfig
{
PublishVerificationResults = true,
ProviderVersion = "1.0.0"
};

var config = GetSubject(baseUri: baseUri, pactUri: pactUri, providerStateSetupUri: providerStateSetupUri, verifierConfig: verifierConfig);

Expand Down
4 changes: 2 additions & 2 deletions PactNet.Tests/PactNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="PactNet-Windows" Version="2.0.22" />
<PackageReference Include="PactNet-Windows" Version="2.0.5-beta" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1'">
<PackageReference Include="System.Net.Http" Version="4.3.1" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PactNet\PactNet.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion PactNet.Tests/PactPublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PactNet.Tests
{
public class PactPublisherTests
{
private const string PactFilePath = @"..\..\..\..\Samples\EventApi\Consumer.Tests\pacts\event_api_consumer-event_api.json";
private static string PactFilePath = Path.GetFullPath(@"..\..\..\..\Samples\EventApi\Consumer.Tests\pacts\event_api_consumer-event_api.json");
private const string ConsumerVersion = "1.0.2";
private const string BrokerBaseUriHttp = "http://test.pact.dius.com.au";
private const string BrokerBaseUriHttps = "https://test.pact.dius.com.au";
Expand Down
17 changes: 10 additions & 7 deletions PactNet.Tests/PactVerifierTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using NSubstitute;
using PactNet.Core;
using Xunit;
Expand All @@ -18,9 +19,11 @@ private IPactVerifier GetSubject()
[Fact]
public void PactVerifier_WhenCalledWithPublishVerificationResultsAndNoProviderVersion_ThrowsArgumentException()
{
var config = new PactVerifierConfig();
config.PublishVerificationResults = true;
config.ProviderVersion = string.Empty;
var config = new PactVerifierConfig
{
PublishVerificationResults = true,
ProviderVersion = string.Empty
};

Assert.Throws<ArgumentException>(() => new PactVerifier(config));
}
Expand Down Expand Up @@ -171,7 +174,7 @@ public void PactUri_WhenCalledWithEmptyUri_ThrowsArgumentException()
[Fact]
public void PactUri_WhenCalledWithUri_SetsPactFileUri()
{
const string pactFileUri = "../../../Consumer.Tests/pacts/my_client-event_api.json";
var pactFileUri = Path.GetFullPath("..\\..\\..\\Consumer.Tests\\pacts\\my_client-event_api.json");
var pactVerifier = GetSubject();

pactVerifier.PactUri(pactFileUri);
Expand All @@ -182,7 +185,7 @@ public void PactUri_WhenCalledWithUri_SetsPactFileUri()
[Fact]
public void PactUri_WhenCalledWithUriInADifferentFormat_SetsPactFileUri()
{
const string pactFileUri = "..\\..\\..\\Consumer.Tests\\pacts\\my_client-event_api.json";
var pactFileUri = Path.GetFullPath("..\\..\\..\\Consumer.Tests\\pacts\\my_client-event_api.json");
var pactVerifier = GetSubject();

pactVerifier.PactUri(pactFileUri);
Expand All @@ -194,7 +197,7 @@ public void PactUri_WhenCalledWithUriInADifferentFormat_SetsPactFileUri()
public void Verify_WhenServiceBaseUriIsNull_ThrowsInvalidOperationException()
{
var pactVerifier = GetSubject();
pactVerifier.PactUri("../../../Consumer.Tests/pacts/my_client-event_api.json");
pactVerifier.PactUri(Path.GetFullPath("..\\..\\..\\Consumer.Tests\\pacts\\my_client-event_api.json"));

Assert.Throws<InvalidOperationException>(() => pactVerifier.Verify());
}
Expand All @@ -213,7 +216,7 @@ public void Verify_WhenTheVerifierIsCorrectlySetUpWithALocalPactFile_PactVerifyC
{
var serviceProvider = "Event API";
var serviceConsumer = "My client";
var pactUri = "../../../Consumer.Tests/pacts/my_client-event_api.json";
var pactUri = Path.GetFullPath("..\\..\\..\\Consumer.Tests\\pacts\\my_client-event_api.json");

var pactVerifier = GetSubject();
pactVerifier
Expand Down
8 changes: 5 additions & 3 deletions PactNet/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace PactNet
using System.IO;

namespace PactNet
{
internal static class Constants
{
public const string AdministrativeRequestHeaderKey = "X-Pact-Mock-Service";
public const string InteractionsPath = "/interactions";
public const string InteractionsVerificationPath = "/interactions/verification";
public const string PactPath = "/pact";
public const string DefaultPactDir = @"..\..\pacts\";
public const string DefaultLogDir = @"..\..\logs\";
public static string DefaultPactDir = Path.GetFullPath(@"..\..\pacts\");
public static string DefaultLogDir = Path.GetFullPath(@"..\..\logs\");
}
}
2 changes: 1 addition & 1 deletion PactNet/Core/MockProviderHostConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public MockProviderHostConfig(int port, bool enableSsl, string providerName, Pac
var logFile = $"{config.LogDir}{providerName.ToLowerSnakeCase()}_mock_service.log";
var sslOption = enableSsl ? " --ssl" : "";

Script = "pact-mock-service.rb";
Script = "pact-mock-service";
Arguments = $"-p {port} -l \"{FixPathForRuby(logFile)}\" --pact-dir \"{FixPathForRuby(config.PactDir)}\" --pact-specification-version \"{config.SpecificationVersion}\"{sslOption}";
WaitForExit = false;
Outputters = config?.Outputters;
Expand Down
Loading

0 comments on commit 370fa70

Please sign in to comment.