1
0
mirror of https://github.com/bitwarden/server synced 2026-01-19 08:53:57 +00:00

Fix tests

This commit is contained in:
Hinton
2025-11-14 14:31:32 +01:00
parent dff45c137d
commit d9b5ab2f67
6 changed files with 92 additions and 52 deletions

View File

@@ -18,11 +18,11 @@ public class QueryController(ILogger<QueryController> logger, IQueryService quer
return Json(result);
}
catch (SceneNotFoundException ex)
catch (QueryNotFoundException ex)
{
return NotFound(new { Error = ex.Message });
}
catch (SceneExecutionException ex)
catch (QueryExecutionException ex)
{
logger.LogError(ex, "Error executing query: {Query}", request.Template);
return BadRequest(new { Error = ex.Message, Details = ex.InnerException?.Message });

View File

@@ -21,6 +21,7 @@ builder.Services.AddScoped<Microsoft.AspNetCore.Identity.IPasswordHasher<Bit.Cor
builder.Services.AddSingleton<Bit.RustSDK.RustSdkService>();
builder.Services.AddScoped<Bit.Seeder.Factories.UserSeeder>();
builder.Services.AddScoped<ISceneService, SceneService>();
builder.Services.AddScoped<IQueryService, QueryService>();
builder.Services.AddScoped<MangleId>(_ => new MangleId());
builder.Services.AddScenes();
builder.Services.AddQueries();
@@ -41,3 +42,6 @@ app.UseRouting();
app.MapControllerRoute(name: "default", pattern: "{controller=Seed}/{action=Index}/{id?}");
app.Run();
// Make Program class accessible for integration tests
public partial class Program { }

View File

@@ -43,12 +43,13 @@ public class SceneService(
var userIds = playData.Select(pd => pd.UserId).Distinct().ToList();
var organizationIds = playData.Select(pd => pd.OrganizationId).Distinct().ToList();
// Delete Users before Oraganizations to respect foreign key constraints
// Delete Users before Organizations to respect foreign key constraints
if (userIds.Count > 0)
{
var users = databaseContext.Users.Where(u => userIds.Contains(u.Id));
await userRepository.DeleteManyAsync(users);
}
if (organizationIds.Count > 0)
{
var organizations = databaseContext.Organizations.Where(o => organizationIds.Contains(o.Id));