Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/1.12.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Aug 17, 2020
2 parents 3690475 + aac559c commit f2a3d10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public static IEnumerable<object[]> Build_Url_Empty_Data
{
foreach (var job in possibleDummies)
{
if (string.IsNullOrEmpty(domain) || string.IsNullOrEmpty(account) || string.IsNullOrEmpty(slug) || string.IsNullOrEmpty(job))
foreach (var build in possibleDummies)
{
yield return new object[] { domain, account, slug, job };
if (string.IsNullOrEmpty(domain) || string.IsNullOrEmpty(account) || string.IsNullOrEmpty(slug) || string.IsNullOrEmpty(job) || string.IsNullOrEmpty(build))
{
yield return new object[] { domain, account, slug, job, build };
}
}
}
}
Expand Down Expand Up @@ -95,14 +98,15 @@ public void Build_Should_Be_Set_When_Enviornment_Variable_Exits()
}

[Theory, MemberData(nameof(Build_Url_Empty_Data))]
public void BuildUrl_Should_Be_Empty_String_When_Environment_Variables_Do_Not_Exist(string appveyorUrl, string accountData, string slugData, string jobId)
public void BuildUrl_Should_Be_Empty_String_When_Environment_Variables_Do_Not_Exist(string appveyorUrl, string accountData, string slugData, string jobId, string buildId)
{
// Given
var ev = new Mock<IEnviornmentVariables>();
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_URL")).Returns(appveyorUrl);
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_ACCOUNT_NAME")).Returns(accountData);
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_PROJECT_SLUG")).Returns(slugData);
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_JOB_ID")).Returns(jobId);
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_BUILD_ID")).Returns(buildId);
var appVeyor = new AppVeyor(ev.Object);

// When
Expand All @@ -121,6 +125,7 @@ public void BuildUrl_Should_Be_Empty_When_Appveyor_Url_Is_Invalid_Domain(string
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_ACCOUNT_NAME")).Returns("foo");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_PROJECT_SLUG")).Returns("bar");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_JOB_ID")).Returns("xyz");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_BUILD_ID")).Returns("zyx");
var appVeyor = new AppVeyor(ev.Object);

// When
Expand All @@ -139,13 +144,14 @@ public void BuildUrl_Should_Not_Empty_String_When_Environment_Variable_Exists()
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_ACCOUNT_NAME")).Returns("foo");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_PROJECT_SLUG")).Returns("bar");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_JOB_ID")).Returns("xyz");
ev.Setup(s => s.GetEnvironmentVariable("APPVEYOR_BUILD_ID")).Returns("zyx");
var appVeyor = new AppVeyor(ev.Object);

// When
var buildUrl = appVeyor.BuildUrl;

// Then
buildUrl.Should().Be("https://ci.appveyor.com/project/foo/bar/build/job/xyz");
buildUrl.Should().Be("https://ci.appveyor.com/project/foo/bar/builds/zyx/job/xyz");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ private string LoadBuildUrl()
var accountName = GetEnvironmentVariable("APPVEYOR_ACCOUNT_NAME");
var slug = GetEnvironmentVariable("APPVEYOR_PROJECT_SLUG");
var jobId = GetEnvironmentVariable("APPVEYOR_JOB_ID");
var buildId = GetEnvironmentVariable("APPVEYOR_BUILD_ID");

if (IsNullOrEmpty(hostUrl, accountName, slug, jobId) || !Uri.TryCreate(hostUrl, UriKind.Absolute, out var uri) || (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps))
if (IsNullOrEmpty(hostUrl, accountName, slug, jobId, buildId) || !Uri.TryCreate(hostUrl, UriKind.Absolute, out var uri) || (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps))
{
return string.Empty;
}

var jobUrl = $"{hostUrl}/project/{accountName}/{slug}/build/job/{jobId}";
var jobUrl = $"{hostUrl}/project/{accountName}/{slug}/builds/{buildId}/job/{jobId}";
return jobUrl;
}

Expand Down

0 comments on commit f2a3d10

Please sign in to comment.