Skip to content

Commit

Permalink
fix base provider
Browse files Browse the repository at this point in the history
  • Loading branch information
followynne committed Oct 4, 2024
1 parent d2e4d58 commit 9df5ae3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.5" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.*" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<ItemGroup>
<PackageReference Include="Serilog.Sinks.SQLite" Version="6.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
28 changes: 11 additions & 17 deletions tests/Serilog.Ui.SqliteProvider.Tests/Util/SqliteTestProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Data.Sqlite;
using Serilog;
using Serilog.Ui.Common.Tests.DataSamples;
using Serilog.Ui.Common.Tests.SqlUtil;
using Serilog.Ui.Common.Tests.TestSuites;
using Serilog.Ui.Core;
using Serilog.Ui.Core.Extensions;
Expand All @@ -28,26 +27,28 @@ public SqliteTestProvider() : base()
// No need to set up a container for SQLite - using in-memory database
}

public SqliteDbOptions DbOptions { get; set; } = new SqliteDbOptions().WithTable("Logs");
public SqliteDbOptions DbOptions { get; set; } = new SqliteDbOptions()
.WithTable("Logs")
.WithConnectionString("Data Source=hello.db");

private async Task CheckDbReadinessAsync()
{
Guard.Against.Null(DbOptions);

using var connection = new SqliteConnection("DataSource=:memory:");
using var connection = new SqliteConnection(DbOptions.ConnectionString);
await connection.OpenAsync();

DbOptions.WithConnectionString(connection.ConnectionString);

await connection.ExecuteAsync("SELECT 1");

InitializeAdditional();
}

private void InitializeAdditional()
{
var serilog = new SerilogSinkSetup(logger =>
logger
.WriteTo
.SQLite(DbOptions.ConnectionString));
.SQLite(@"hello.db", batchSize: 1));
_collector = serilog.InitializeLogs();

_provider = new SqliteDataProvider(DbOptions, new SqliteQueryBuilder());
Expand All @@ -57,20 +58,13 @@ private void InitializeAdditional()

public LogModelPropsCollector GetPropsCollector() => _collector!;

public async Task InitializeAsync()
public Task InitializeAsync()
{
await CheckDbReadinessAsync();
InitializeAdditional();
return CheckDbReadinessAsync();
}

public Task DisposeAsync()
{
return Task.CompletedTask;
}

public void Dispose()
{
public Task DisposeAsync() => Task.CompletedTask;

}
public void Dispose() { }
}
}

0 comments on commit 9df5ae3

Please sign in to comment.