Public Access
Implement meeting assistant v1
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using MeetingAssistant.Recording;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace MeetingAssistant.Tests;
|
||||
|
||||
@@ -10,7 +16,16 @@ public sealed class HealthEndpointTests : IClassFixture<WebApplicationFactory<Pr
|
||||
|
||||
public HealthEndpointTests(WebApplicationFactory<Program> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
this.factory = factory.WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.ConfigureAppConfiguration((_, configuration) =>
|
||||
{
|
||||
configuration.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["MeetingAssistant:FunAsr:Backend:Enabled"] = "false"
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -26,5 +41,41 @@ public sealed class HealthEndpointTests : IClassFixture<WebApplicationFactory<Pr
|
||||
Assert.Equal("ok", body?.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ApplicationStartupDeletesStaleTemporaryRecordings()
|
||||
{
|
||||
await using var cleanupFactory = factory.WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.ConfigureTestServices(services =>
|
||||
{
|
||||
services.RemoveAll<IRecordedAudioStore>();
|
||||
services.AddSingleton<IRecordedAudioStore, StartupCleanupRecordedAudioStore>();
|
||||
});
|
||||
});
|
||||
using var client = cleanupFactory.CreateClient();
|
||||
|
||||
using var response = await client.GetAsync("/health");
|
||||
var store = cleanupFactory.Services.GetRequiredService<IRecordedAudioStore>() as StartupCleanupRecordedAudioStore;
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.True(store?.StaleRecordingsDeleted);
|
||||
}
|
||||
|
||||
private sealed record HealthResponse(string Service, string Status);
|
||||
|
||||
private sealed class StartupCleanupRecordedAudioStore : IRecordedAudioStore
|
||||
{
|
||||
public bool StaleRecordingsDeleted { get; private set; }
|
||||
|
||||
public Task<IRecordedAudioSink> CreateSessionAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Task DeleteStaleRecordingsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
StaleRecordingsDeleted = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user