Skip UseFileServer when wwwroot is missing.
Local Aspire has no published client folder; the middleware warned on every boot. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
namespace HSchool.Server.Tests;
|
||||
|
||||
public class ClientStaticFilesTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanServe_IsFalseWhenTheDirectoryIsMissing()
|
||||
{
|
||||
var missing = Path.Combine(Path.GetTempPath(), "h-school-no-wwwroot-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
Assert.False(ClientStaticFiles.CanServe(missing));
|
||||
Assert.False(ClientStaticFiles.CanServe(null));
|
||||
Assert.False(ClientStaticFiles.CanServe(""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanServe_IsTrueWhenTheDirectoryExists()
|
||||
{
|
||||
var directory = Directory.CreateTempSubdirectory("h-school-wwwroot-");
|
||||
try
|
||||
{
|
||||
Assert.True(ClientStaticFiles.CanServe(directory.FullName));
|
||||
}
|
||||
finally
|
||||
{
|
||||
directory.Delete(recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user