Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Mar 25, 2024
1 parent 2fc8455 commit 0d5aa50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Aspire.Dashboard/DashboardWebApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public DashboardWebApplication(Action<WebApplicationBuilder>? configureBuilder =
builder.Logging.AddFilter("Microsoft.AspNetCore.Server.Kestrel", LogLevel.Error);
#endif

// Allow for a user specified JSON config file on disk. Throw an error if the specified file doesn't exist.
if (builder.Configuration[DashboardConfigNames.DashboardConfigFilePathName.ConfigKey] is { Length: > 0 } configFilePath)
{
builder.Configuration.AddJsonFile(configFilePath, optional: true, reloadOnChange: true);
builder.Configuration.AddJsonFile(configFilePath, optional: false, reloadOnChange: true);
}

var dashboardConfigSection = builder.Configuration.GetSection("Dashboard");
Expand Down
18 changes: 18 additions & 0 deletions tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ public async Task Configuration_NoExtraConfig_Error()
s => s.Contains("Dashboard:Otlp:AuthMode"));
}

[Fact]
public async Task Configuration_ConfigFilePathDoesntExist_Error()
{
// Arrange & Act
var configFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var ex = await Assert.ThrowsAsync<FileNotFoundException>(async () =>
{
await using var app = IntegrationTestHelpers.CreateDashboardWebApplication(_testOutputHelper,
additionalConfiguration: data =>
{
data[DashboardConfigNames.DashboardConfigFilePathName.ConfigKey] = configFilePath;
});
});

// Assert
Assert.Contains(configFilePath, ex.Message);
}

[Fact]
public async Task Configuration_OptionsMonitor_CanReadConfiguration()
{
Expand Down

0 comments on commit 0d5aa50

Please sign in to comment.