Skip to content

Commit 9b989ae

Browse files
committed
chore: increase ParseTimeoutMs to 5000 in MqlController
1 parent 47ce355 commit 9b989ae

2 files changed

Lines changed: 63 additions & 4 deletions

File tree

src/Melodee.Mql/Api/MqlController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MqlController : ControllerBase
2727
private readonly ILogger<MqlController> _logger;
2828

2929
private const int MaxQueryLength = 500;
30-
private const int ParseTimeoutMs = 200;
30+
private const int ParseTimeoutMs = 5000;
3131
private const int RateLimitRequests = 10;
3232
private static readonly TimeSpan RateLimitWindow = TimeSpan.FromMinutes(1);
3333

tests/Melodee.Tests.Blazor/ScalarIntegrationTests.cs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,75 @@
11
using System.Net;
22
using FluentAssertions;
3+
using Melodee.Common.Data;
4+
using Melodee.Common.Models.SearchEngines.ArtistSearchEngineServiceData;
5+
using Melodee.Common.Plugins.SearchEngine.MusicBrainz.Data;
36
using Microsoft.AspNetCore.Mvc.Testing;
7+
using Microsoft.EntityFrameworkCore;
8+
using Microsoft.EntityFrameworkCore.Infrastructure;
9+
using Microsoft.Extensions.Configuration;
10+
using Microsoft.Extensions.DependencyInjection;
11+
using Microsoft.Extensions.Options;
412

513
namespace Melodee.Tests.Blazor;
614

7-
public class ScalarIntegrationTests : IClassFixture<WebApplicationFactory<Program>>
15+
public class ScalarIntegrationTests : IAsyncLifetime
816
{
917
private readonly WebApplicationFactory<Program> _factory;
1018

11-
public ScalarIntegrationTests(WebApplicationFactory<Program> factory)
19+
public ScalarIntegrationTests()
1220
{
13-
_factory = factory;
21+
var inMemoryProvider = new ServiceCollection()
22+
.AddEntityFrameworkInMemoryDatabase()
23+
.BuildServiceProvider();
24+
25+
_factory = new WebApplicationFactory<Program>()
26+
.WithWebHostBuilder(builder =>
27+
{
28+
builder.ConfigureAppConfiguration((_, config) =>
29+
{
30+
var settings = new Dictionary<string, string?>
31+
{
32+
["ConnectionStrings:DefaultConnection"] = "Host=localhost;Database=melodee_test;Username=test;Password=test",
33+
["ConnectionStrings:ArtistSearchEngineConnection"] = "Data Source=:memory:",
34+
["ConnectionStrings:MusicBrainzConnection"] = "Data Source=:memory:",
35+
["Jwt:Key"] = new string('k', 64),
36+
["Jwt:Issuer"] = "melodee-tests",
37+
["Jwt:Audience"] = "melodee-tests",
38+
["security.secretKey"] = new string('s', 32),
39+
["QuartzDisabled"] = "true"
40+
};
41+
42+
config.AddInMemoryCollection(settings);
43+
});
44+
45+
builder.ConfigureServices(services =>
46+
{
47+
var descriptors = services.Where(d =>
48+
d.ServiceType == typeof(DbContextOptions<MelodeeDbContext>) ||
49+
d.ServiceType == typeof(IDbContextFactory<MelodeeDbContext>) ||
50+
d.ServiceType == typeof(IDbContextOptionsConfiguration<MelodeeDbContext>) ||
51+
d.ServiceType == typeof(IConfigureOptions<DbContextOptions<MelodeeDbContext>>))
52+
.ToList();
53+
54+
foreach (var descriptor in descriptors)
55+
{
56+
services.Remove(descriptor);
57+
}
58+
59+
services.AddDbContextFactory<MelodeeDbContext>(options =>
60+
{
61+
options.UseInMemoryDatabase("ScalarIntegrationTests");
62+
options.UseInternalServiceProvider(inMemoryProvider);
63+
});
64+
});
65+
});
66+
}
67+
68+
public Task InitializeAsync() => Task.CompletedTask;
69+
70+
public async Task DisposeAsync()
71+
{
72+
await _factory.DisposeAsync();
1473
}
1574

1675
[Fact]

0 commit comments

Comments
 (0)