Skip to content

Commit

Permalink
Merge pull request #117 from AutomatedArchitecture/feature/112-tfs-lo…
Browse files Browse the repository at this point in the history
…ckup

Bug #112: tfs lockup
  • Loading branch information
lprichar committed Jan 24, 2018
2 parents b398e6a + 17dfbbc commit a4bb736
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
18 changes: 18 additions & 0 deletions SirenOfShame.Test.Unit/TfsRestServices/TfsRestWatcherTest.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using SirenOfShame.Lib.Exceptions;
Expand Down Expand Up @@ -97,6 +98,23 @@ public void GivenHttpRequestException_WhenGettingBuildStatus_ThenServerUnavailab
);
}

[Test]
public void GivenTaskCanceledExceptionAkaTimeout_WhenGettingBuildStatus_ThenServerUnavailableException()
{
// arrange
var buildDefinitionSettings = new[] {new BuildDefinitionSetting()};
var tfsRestService = new Mock<TfsRestService>();
var ciEntryPointSetting = new CiEntryPointSetting { Url = "url" };
tfsRestService.Setup(i => i.GetBuildsStatuses(ciEntryPointSetting, buildDefinitionSettings))
.ThrowsAsync(new TaskCanceledException());
var tfsRestWatcher = new MyTfsRestWatcher(tfsRestService.Object, buildDefinitionSettings, ciEntryPointSetting);

// assert & act
Assert.Throws<ServerUnavailableException>(() =>
tfsRestWatcher.MyGetBuildStatus()
);
}

[Test]
public void GivenHttpRequestExceptionWith401InMessage_WhenGettingBuildStatus_ThenInvalidCredentialsException()
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion TfsRestServices/TfsRestServices.csproj
Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<OutputPath>..\SirenOfShame\bin\Plugins\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
Expand Down
7 changes: 2 additions & 5 deletions TfsRestServices/TfsRestWatcher.cs
Expand Up @@ -46,11 +46,6 @@ protected override IList<BuildStatus> GetBuildStatus()
throw new ServerUnavailableException();
}

var taskCancelledException = ex.InnerExceptions.FirstOrDefault(x => x is TaskCanceledException);
if (!ReferenceEquals(null, taskCancelledException))
{
throw taskCancelledException;
}
throw;
}
catch (WebException ex)
Expand All @@ -75,6 +70,8 @@ private static bool IsInvalidCredentials(Exception ex)

private static bool IsServerUnavailable(Exception ex)
{
if (ex is TaskCanceledException)
return true;
if (ex is WebException webException)
return IsServerUnavailable(webException);
if (ex is HttpRequestException httpRequestException)
Expand Down

0 comments on commit a4bb736

Please sign in to comment.