mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-08 19:42:27 +00:00
Fix authentication (mostly) and file upload tests failing
This commit is contained in:
parent
8289e6c04e
commit
0d682dceeb
5 changed files with 25 additions and 13 deletions
29
ProjectLighthouse.Tests/DatabaseFactAttribute.cs
Normal file
29
ProjectLighthouse.Tests/DatabaseFactAttribute.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests
|
||||
{
|
||||
public sealed class DatabaseFactAttribute : FactAttribute
|
||||
{
|
||||
private static readonly object migrateLock = new();
|
||||
|
||||
public DatabaseFactAttribute()
|
||||
{
|
||||
ServerSettings.Instance = new ServerSettings();
|
||||
ServerSettings.Instance.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
|
||||
if (!ServerStatics.DbConnected)
|
||||
{
|
||||
this.Skip = "Database not available";
|
||||
}
|
||||
else
|
||||
{
|
||||
lock(migrateLock)
|
||||
{
|
||||
using Database database = new();
|
||||
database.Database.Migrate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue