Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-sharma committed Aug 1, 2018
1 parent c1f1fce commit 0ae7826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/NuGet.Services.Revalidate/Services/HealthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public async Task<bool> IsHealthyAsync()
if (component == null)
{
_logger.LogError(
"Could not find component path {ComponentPath} in status health blob!",
"Assuming that the service is unhealthy as the component path {ComponentPath} could not be found",
_config.ComponentPath);

throw new InvalidOperationException($"Could not find component path '{_config.ComponentPath}' in status health blob!");
return false;
}

return component.Status == ComponentStatus.Up;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,29 @@ public async Task ReturnsHealthyIfStatusBlobIndicatesHealthyComponent(string res
}

[Fact]
public async Task ThrowsIfStatusBlobIsMissingExpectedPath()
public async Task AssumesUnhealthyIfComponentCannotBeFoundInStatusBlob()
{
_storage
.Setup(s => s.GetFileAsync(_config.ContainerName, _config.StatusBlobName))
.ReturnsAsync(TestResources.GetResourceStream(TestResources.PackagePublishingMissingStatus));

var e = await Assert.ThrowsAsync<InvalidOperationException>(() => _target.IsHealthyAsync());

Assert.Equal("Could not find component path 'NuGet/Package Publishing' in status health blob!", e.Message);
Assert.False(await _target.IsHealthyAsync());
}

[Fact]
public async Task ThrowsIfStorageServiceThrows()
{
// This may happen if the status blob can't be found.
var expectedException = new Exception("Look ma, I'm an exception!");

_storage
.Setup(s => s.GetFileAsync(_config.ContainerName, _config.StatusBlobName))
.ThrowsAsync(new Exception());
.ThrowsAsync(expectedException);

// Act & Assert
var actualException = await Assert.ThrowsAsync<Exception>(() => _target.IsHealthyAsync());

await Assert.ThrowsAsync<Exception>(() => _target.IsHealthyAsync());
Assert.Same(expectedException, actualException);
}
}
}

0 comments on commit 0ae7826

Please sign in to comment.