-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for Atlassian Bamboo Build Server.
- Loading branch information
Showing
23 changed files
with
1,241 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Cake.Common.Build.Bamboo; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using NSubstitute; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Build | ||
{ | ||
internal sealed class BambooFixture | ||
{ | ||
public ICakeEnvironment Environment { get; set; } | ||
|
||
public BambooFixture() | ||
{ | ||
Environment = Substitute.For<ICakeEnvironment>(); | ||
Environment.WorkingDirectory.Returns("C:\\build\\CAKE-CAKE-JOB1"); | ||
Environment.GetEnvironmentVariable("bamboo_buildNumber").Returns((string)null); | ||
} | ||
|
||
public void IsRunningOnBamboo() | ||
{ | ||
Environment.GetEnvironmentVariable("bamboo_buildNumber").Returns("28"); | ||
} | ||
|
||
public BambooProvider CreateBambooService() | ||
{ | ||
return new BambooProvider(Environment); | ||
} | ||
} | ||
} |
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,73 @@ | ||
using Cake.Common.Build.Bamboo.Data; | ||
using Cake.Core; | ||
using NSubstitute; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Build | ||
{ | ||
internal sealed class BambooInfoFixture | ||
{ | ||
public ICakeEnvironment Environment { get; set; } | ||
|
||
public BambooInfoFixture() | ||
{ | ||
Environment = Substitute.For<ICakeEnvironment>(); | ||
|
||
//BambooBuildInfo | ||
Environment.GetEnvironmentVariable("bamboo_build_working_directory").Returns("C:\\build\\CAKE-CAKE-JOB1"); | ||
Environment.GetEnvironmentVariable("bamboo_buildNumber").Returns("28"); | ||
Environment.GetEnvironmentVariable("bamboo_buildKey").Returns("CAKE-CAKE-JOB1"); | ||
Environment.GetEnvironmentVariable("bamboo_buildResultKey").Returns("CAKE-CAKE-JOB1-28"); | ||
Environment.GetEnvironmentVariable("bamboo_buildResultsUrl").Returns("https://cakebuild.atlassian.net/builds/browse/CAKE-CAKE-JOB1-28"); | ||
Environment.GetEnvironmentVariable("bamboo_buildTimeStamp").Returns("2015-12-15T22:53:37.847+01:00"); | ||
|
||
//BambooCustomBuildInfo | ||
Environment.GetEnvironmentVariable("bamboo_customRevision").Returns("Cake with Iceing"); | ||
|
||
//BambooCommitInfo | ||
Environment.GetEnvironmentVariable("bamboo_planRepository_revision").Returns("d4a3a4cb304548450e3cab2ff735f778ffe58d03"); | ||
|
||
//BambooPlanInfo | ||
Environment.GetEnvironmentVariable("bamboo_planKey").Returns("CAKE-CAKE"); | ||
Environment.GetEnvironmentVariable ("bamboo_planName").Returns ("cake-bamboo - dev"); | ||
Environment.GetEnvironmentVariable("bamboo_shortJobKey").Returns("JOB1"); | ||
Environment.GetEnvironmentVariable("bamboo_shortJobName").Returns("Build Cake"); | ||
Environment.GetEnvironmentVariable("bamboo_shortPlanKey").Returns("CAKE"); | ||
Environment.GetEnvironmentVariable("bamboo_shortPlanName").Returns("Cake"); | ||
|
||
//BambooRepositoryInfo | ||
Environment.GetEnvironmentVariable("bamboo_planRepository_type").Returns("git"); | ||
Environment.GetEnvironmentVariable("bamboo_repository_name").Returns("Cake/Develop"); | ||
Environment.GetEnvironmentVariable("bamboo_planRepository_branch").Returns("develop"); | ||
} | ||
|
||
public BambooBuildInfo CreateBuildInfo() | ||
{ | ||
return new BambooBuildInfo(Environment); | ||
} | ||
|
||
public BambooPlanInfo CreatePlanInfo() | ||
{ | ||
return new BambooPlanInfo(Environment); | ||
} | ||
|
||
public BambooCommitInfo CreateCommitInfo() | ||
{ | ||
return new BambooCommitInfo(Environment); | ||
} | ||
|
||
public BambooRepositoryInfo CreateRepositoryInfo() | ||
{ | ||
return new BambooRepositoryInfo(Environment); | ||
} | ||
|
||
public BambooCustomBuildInfo CreateCustomBuildInfo() | ||
{ | ||
return new BambooCustomBuildInfo(Environment); | ||
} | ||
|
||
public BambooEnvironmentInfo CreateEnvironmentInfo() | ||
{ | ||
return new BambooEnvironmentInfo(Environment); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/Cake.Common.Tests/Unit/Build/Bamboo/BambooProviderTests.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,74 @@ | ||
using Cake.Common.Build.Bamboo; | ||
using Cake.Common.Tests.Fixtures.Build; | ||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Build.Bamboo | ||
{ | ||
public sealed class BambooProviderTests | ||
{ | ||
public sealed class TheConstructor | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Environment_Is_Null() | ||
{ | ||
// Given, When | ||
var result = Record.Exception(() => new BambooProvider(null)); | ||
|
||
// Then | ||
Assert.IsArgumentNullException(result, "environment"); | ||
} | ||
} | ||
|
||
public sealed class TheIsRunningOnBambooProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_True_If_Running_On_Bamboo() | ||
{ | ||
// Given | ||
var fixture = new BambooFixture(); | ||
fixture.IsRunningOnBamboo(); | ||
var Bamboo = fixture.CreateBambooService(); | ||
|
||
// When | ||
var result = Bamboo.IsRunningOnBamboo; | ||
|
||
// Then | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_False_If_Not_Running_On_Bamboo() | ||
{ | ||
// Given | ||
var fixture = new BambooFixture(); | ||
var Bamboo = fixture.CreateBambooService(); | ||
|
||
// When | ||
var result = Bamboo.IsRunningOnBamboo; | ||
|
||
// Then | ||
Assert.False(result); | ||
} | ||
} | ||
|
||
public sealed class TheEnvironmentProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Non_Null_Reference() | ||
{ | ||
// Given | ||
var fixture = new BambooFixture(); | ||
var Bamboo = fixture.CreateBambooService(); | ||
|
||
// When | ||
var result = Bamboo.Environment; | ||
|
||
// Then | ||
Assert.NotNull(result); | ||
} | ||
} | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/Cake.Common.Tests/Unit/Build/Bamboo/Data/BambooBuildInfoTests.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,104 @@ | ||
using Cake.Common.Tests.Fixtures.Build; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Build.Bamboo.Data | ||
{ | ||
public sealed class BambooBuildInfoTests | ||
{ | ||
public sealed class TheFolderProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.Folder; | ||
|
||
// Then | ||
Assert.Equal(@"C:\build\CAKE-CAKE-JOB1", result); | ||
} | ||
} | ||
|
||
public sealed class TheNumberProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.Number; | ||
|
||
// Then | ||
Assert.Equal(28, result); | ||
} | ||
} | ||
|
||
public sealed class TheBuildKeyProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.BuildKey; | ||
|
||
// Then | ||
Assert.Equal("CAKE-CAKE-JOB1", result); | ||
} | ||
} | ||
|
||
public sealed class TheResultKeyProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.ResultKey; | ||
|
||
// Then | ||
Assert.Equal("CAKE-CAKE-JOB1-28", result); | ||
} | ||
} | ||
|
||
public sealed class TheResultUrlProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.ResultsUrl; | ||
|
||
// Then | ||
Assert.Equal("https://cakebuild.atlassian.net/builds/browse/CAKE-CAKE-JOB1-28", result); | ||
} | ||
} | ||
|
||
public sealed class TheBuildTimestampProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateBuildInfo(); | ||
|
||
// When | ||
var result = info.BuildTimestamp; | ||
|
||
// Then | ||
Assert.Equal("2015-12-15T22:53:37.847+01:00", result); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Cake.Common.Tests/Unit/Build/Bamboo/Data/BambooCommitInfoTests.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,25 @@ | ||
using Cake.Common.Tests.Fixtures.Build; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Build.Bamboo.Data | ||
{ | ||
public sealed class BambooCommitInfoTests | ||
{ | ||
public sealed class TheRepositoryRevisionProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateCommitInfo(); | ||
|
||
// When | ||
var result = info.RepositoryRevision; | ||
|
||
// Then | ||
Assert.Equal("d4a3a4cb304548450e3cab2ff735f778ffe58d03", result); | ||
|
||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Cake.Common.Tests/Unit/Build/Bamboo/Data/BambooCustomBuildInfoTests.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,41 @@ | ||
using Cake.Common.Tests.Fixtures.Build; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Build.Bamboo.Data | ||
{ | ||
public sealed class BambooCustomBuildInfoTests | ||
{ | ||
|
||
public sealed class TheIsCustomBuildProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateCustomBuildInfo(); | ||
|
||
// When | ||
var result = info.IsCustomBuild; | ||
|
||
// Then | ||
Assert.Equal(true, result); | ||
} | ||
} | ||
|
||
public sealed class TheRevisonNameProperty | ||
{ | ||
[Fact] | ||
public void Should_Return_Correct_Value() | ||
{ | ||
// Given | ||
var info = new BambooInfoFixture().CreateCustomBuildInfo(); | ||
|
||
// When | ||
var result = info.RevisonName; | ||
|
||
// Then | ||
Assert.Equal("Cake with Iceing", result); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.