Skip to content

tests(mongo-db): move integration to direct sink generation #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to 8.0.*.

<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8"/>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1"/>
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1"/>
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0"/>
Expand Down
4 changes: 2 additions & 2 deletions samples/WebApp/WebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.32"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to 6.0.*.

<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.33"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.20"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8"/>
</ItemGroup>

<!-- Serilog UI packages -->
Expand Down
6 changes: 3 additions & 3 deletions src/Serilog.Ui.MongoDbProvider/MongoDbLogModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text.Json;
Expand All @@ -12,8 +12,8 @@ namespace Serilog.Ui.MongoDbProvider
[BsonDiscriminator(RootClass = true)]
public class MongoDbLogModel
{
[BsonIgnore]
public int Id { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }

public string? Level { get; set; } = string.Empty;

Expand Down
6 changes: 0 additions & 6 deletions src/Serilog.Ui.MsSqlServerProvider/package-lock.json

This file was deleted.

10 changes: 5 additions & 5 deletions src/Serilog.Ui.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.2",
"react-router-dom": "^6.26.0",
"react-router-dom": "^6.26.1",
"xml-formatter": "^3.6.3"
},
"devDependencies": {
Expand All @@ -35,7 +35,7 @@
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.3.0",
"@types/node": "^22.4.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.7.0",
Expand All @@ -61,13 +61,13 @@
"postcss-simple-vars": "^7.0.1",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"shiki": "^1.12.1",
"shiki": "^1.13.0",
"testing-library-selector": "^0.3.1",
"typescript": "^5.5.4",
"typescript-eslint": "^8.1.0",
"vite": "^5.4.0",
"vite": "^5.4.1",
"vite-plugin-checker": "^0.7.2",
"vite-plugin-mkcert": "^1.17.5",
"vite-plugin-mkcert": "^1.17.6",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.0.5",
"vitest-sonar-reporter": "^2.0.0"
Expand Down
100 changes: 50 additions & 50 deletions src/Serilog.Ui.Web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@
"@octokit/types" "^13.1.0"
universal-user-agent "^6.0.0"

"@octokit/rest@^20.0.2":
"@octokit/rest@^20.1.1":
version "20.1.1"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-20.1.1.tgz#ec775864f53fb42037a954b9a40d4f5275b3dc95"
integrity sha512-MB4AYDsM5jhIHro/dq4ix1iWTLGToIGk6cWF5L6vanFaMble5jTX/UBQyiv05HsWnwUtY8JrfHy2LWfKwihqMw==
Expand Down Expand Up @@ -845,10 +845,10 @@
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.25.tgz#f077fdc0b5d0078d30893396ff4827a13f99e817"
integrity sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==

"@remix-run/[email protected].0":
version "1.19.0"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.19.0.tgz#745dbffbce67f05386d57ca22c51dfd85c979593"
integrity sha512-zDICCLKEwbVYTS6TjYaWtHXxkdoUvD/QXvyVZjGCsWz5vyH7aFeONlPffPdW+Y/t6KT0MgXb2Mfjun9YpWN1dA==
"@remix-run/[email protected].1":
version "1.19.1"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.19.1.tgz#984771bfd1de2715f42394c87fb716c1349e014f"
integrity sha512-S45oynt/WH19bHbIXjtli6QmwNYvaz+vtnubvNpNDvUOoA/OWh6j1OikIP3G+v5GHdxyC6EXoChG3HgYGEUfcg==

"@rollup/[email protected]":
version "4.18.0"
Expand Down Expand Up @@ -930,10 +930,10 @@
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.0.tgz#5d694d345ce36b6ecf657349e03eb87297e68da4"
integrity sha512-UOo5FdvOL0+eIVTgS4tIdbW+TtnBLWg1YBCcU2KWM7nuNwRz9bksDX1bekJJCpu25N1DVWaCwnT39dVQxzqS8g==

"@shikijs/core@1.12.1":
version "1.12.1"
resolved "https://registry.yarnpkg.com/@shikijs/core/-/core-1.12.1.tgz#32626494bef573cce01f9e0a36d5776cbc1b2e58"
integrity sha512-biCz/mnkMktImI6hMfMX3H9kOeqsInxWEyCHbSlL8C/2TR1FqfmGxTLRNwYCKsyCyxWLbB8rEqXRVZuyxuLFmA==
"@shikijs/core@1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@shikijs/core/-/core-1.13.0.tgz#ffbdf8d27ce5783d97b979659194367e06b63af7"
integrity sha512-Mj5NVfbAXcD1GnwOTSPl8hBn/T8UDpfFQTptp+p41n/CbUcJtOq98WaRD7Lz3hCglYotUTHUWtzu3JhK6XlkAA==
dependencies:
"@types/hast" "^3.0.4"

Expand Down Expand Up @@ -1128,12 +1128,12 @@
dependencies:
undici-types "~5.26.4"

"@types/node@^22.3.0":
version "22.3.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.3.0.tgz#7f8da0e2b72c27c4f9bd3cb5ef805209d04d4f9e"
integrity sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==
"@types/node@^22.4.0":
version "22.4.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.4.0.tgz#c295fe1d6f5f58916cc61dbef8cf65b5b9b71de9"
integrity sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==
dependencies:
undici-types "~6.18.2"
undici-types "~6.19.2"

"@types/prop-types@*":
version "15.7.12"
Expand Down Expand Up @@ -1670,7 +1670,7 @@ axe-core@^4.9.1:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.10.0.tgz#d9e56ab0147278272739a000880196cdfe113b59"
integrity sha512-Mr2ZakwQ7XUAjp7pAwQWRhhK8mQQ6JAaNWSjmjxil0R8BPioMtQsTLOolGYkji1rcL++3dCqZA3zWqpT+9Ew6g==

axios@^1.6.8:
axios@^1.7.4:
version "1.7.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2"
integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==
Expand Down Expand Up @@ -1970,7 +1970,7 @@ debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4:
dependencies:
ms "2.1.2"

debug@^4.3.5:
debug@^4.3.5, debug@^4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
Expand Down Expand Up @@ -3855,7 +3855,7 @@ postcss@^8.4.38:
picocolors "^1.0.0"
source-map-js "^1.2.0"

postcss@^8.4.40, postcss@^8.4.41:
postcss@^8.4.41:
version "8.4.41"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.41.tgz#d6104d3ba272d882fe18fc07d15dc2da62fa2681"
integrity sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==
Expand Down Expand Up @@ -3978,20 +3978,20 @@ react-remove-scroll@^2.5.7:
use-callback-ref "^1.3.0"
use-sidecar "^1.1.2"

react-router-dom@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.26.0.tgz#8debe13295c58605c04f93018d659a763245e58c"
integrity sha512-RRGUIiDtLrkX3uYcFiCIxKFWMcWQGMojpYZfcstc63A1+sSnVgILGIm9gNUA6na3Fm1QuPGSBQH2EMbAZOnMsQ==
react-router-dom@^6.26.1:
version "6.26.1"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.26.1.tgz#a408892b41767a49dc94b3564b0e7d8e3959f623"
integrity sha512-veut7m41S1fLql4pLhxeSW3jlqs+4MtjRLj0xvuCEXsxusJCbs6I8yn9BxzzDX2XDgafrccY6hwjmd/bL54tFw==
dependencies:
"@remix-run/router" "1.19.0"
react-router "6.26.0"
"@remix-run/router" "1.19.1"
react-router "6.26.1"

[email protected].0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.26.0.tgz#d5af4c46835b202348ef2b7ddacd32a2db539fde"
integrity sha512-wVQq0/iFYd3iZ9H2l3N3k4PL8EEHcb0XlU2Na8nEwmiXgIUElEH6gaJDtUQxJ+JFzmIXaQjfdpcGWaM6IoQGxg==
[email protected].1:
version "6.26.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.26.1.tgz#88c64837e05ffab6899a49df2a1484a22471e4ce"
integrity sha512-kIwJveZNwp7teQRI5QmwWo39A5bXRyqpH0COKKmPnyD2vBvDwgFXSqDUYtt1h+FEyfnE8eXr7oe0MxRzVwCcvQ==
dependencies:
"@remix-run/router" "1.19.0"
"@remix-run/router" "1.19.1"

react-style-singleton@^2.2.1:
version "2.2.1"
Expand Down Expand Up @@ -4218,12 +4218,12 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==

shiki@^1.12.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-1.12.1.tgz#72d9d230a8d68ddaf8cf7c94a1dc6a5f2625324e"
integrity sha512-nwmjbHKnOYYAe1aaQyEBHvQymJgfm86ZSS7fT8OaPRr4sbAcBNz7PbfAikMEFSDQ6se2j2zobkXvVKcBOm0ysg==
shiki@^1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-1.13.0.tgz#129986ad475ad4a962b5c681eabb843e38dde65e"
integrity sha512-e0dWfnONbEv6xl7FJy3XIhsVHQ/65XHDZl92+6H9+4xWjfdo7pmkqG7Kg47KWtDiEtzM5Z+oEfb4vtRvoZ/X9w==
dependencies:
"@shikijs/core" "1.12.1"
"@shikijs/core" "1.13.0"
"@types/hast" "^3.0.4"

side-channel@^1.0.4, side-channel@^1.0.6:
Expand Down Expand Up @@ -4664,10 +4664,10 @@ undici-types@~5.26.4:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici-types@~6.18.2:
version "6.18.2"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.18.2.tgz#8b678cf939d4fc9ec56be3c68ed69c619dee28b0"
integrity sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==
undici-types@~6.19.2:
version "6.19.6"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.6.tgz#e218c3df0987f4c0e0008ca00d6b6472d9b89b36"
integrity sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==

universal-user-agent@^6.0.0:
version "6.0.1"
Expand Down Expand Up @@ -4775,15 +4775,15 @@ vite-plugin-checker@^0.7.2:
vscode-languageserver-textdocument "^1.0.1"
vscode-uri "^3.0.2"

vite-plugin-mkcert@^1.17.5:
version "1.17.5"
resolved "https://registry.yarnpkg.com/vite-plugin-mkcert/-/vite-plugin-mkcert-1.17.5.tgz#175f1a2a99c110fa87b2f2e6390b22656674a67b"
integrity sha512-KKGY3iHx/9zb7ow8JJ+nLN2HiNIBuPBwj34fJ+jAJT89/8qfk7msO7G7qipR8VDEm9xMCys0xT11QOJbZcg3/Q==
vite-plugin-mkcert@^1.17.6:
version "1.17.6"
resolved "https://registry.yarnpkg.com/vite-plugin-mkcert/-/vite-plugin-mkcert-1.17.6.tgz#c514d3d72ba201997e29cc537538bf8ff126c5c2"
integrity sha512-4JR1RN0HEg/w17eRQJ/Ve2pSa6KCVQcQO6yKtIaKQCFDyd63zGfXHWpygBkvvRSpqa0GcqNKf0fjUJ0HiJQXVQ==
dependencies:
"@octokit/rest" "^20.0.2"
axios "^1.6.8"
debug "^4.3.4"
picocolors "^1.0.0"
"@octokit/rest" "^20.1.1"
axios "^1.7.4"
debug "^4.3.6"
picocolors "^1.0.1"

vite-tsconfig-paths@^5.0.1:
version "5.0.1"
Expand All @@ -4805,13 +4805,13 @@ vite@^5.0.0:
optionalDependencies:
fsevents "~2.3.3"

vite@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.0.tgz#11dca8a961369ba8b5cae42d068c7ad684d5370f"
integrity sha512-5xokfMX0PIiwCMCMb9ZJcMyh5wbBun0zUzKib+L65vAZ8GY9ePZMXxFrHbr/Kyll2+LSCY7xtERPpxkBDKngwg==
vite@^5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.1.tgz#2aa72370de824d23f53658affd807e4c9905b058"
integrity sha512-1oE6yuNXssjrZdblI9AfBbHCC41nnyoVoEZxQnID6yvQZAFBzxxkqoFLtHUMkYunL8hwOLEjgTuxpkRxvba3kA==
dependencies:
esbuild "^0.21.3"
postcss "^8.4.40"
postcss "^8.4.41"
rollup "^4.13.0"
optionalDependencies:
fsevents "~2.3.3"
Expand Down
39 changes: 0 additions & 39 deletions tests/Serilog.Ui.Common.Tests/DataSamples/MongoDbLogModelFaker.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Primitives;
using MongoDb.Tests.Util;
using MongoDb.Tests.Util;
using Serilog.Ui.Common.Tests.TestSuites.Impl;
using Serilog.Ui.Core.Models;
using Serilog.Ui.MongoDbProvider;
using Xunit;

namespace MongoDb.Tests.DataProvider
{
[Collection(nameof(MongoDbDataProvider))]
[Trait("Integration-Search", "MongoDb")]
public class DataProviderSearchTest(BaseIntegrationTest instance) : IntegrationSearchTests<BaseIntegrationTest>(instance)
{
public override async Task It_finds_only_data_emitted_in_dates_range()
{
var firstTimeStamp = LogCollector.TimesSamples.First().AddSeconds(50);
var lastTimeStamp = LogCollector.TimesSamples.Last().AddSeconds(50);
var inTimeStampCount = LogCollector.DataSet
.Count(p => p.Timestamp >= firstTimeStamp && p.Timestamp < lastTimeStamp);
var query = new Dictionary<string, StringValues>
{
["page"] = "1",
["count"] = "1000",
["startDate"] = firstTimeStamp.ToString("O"),
["endDate"] = lastTimeStamp.ToString("O")
};

var (logs, count) = await Provider.FetchDataAsync(FetchLogsQuery.ParseQuery(query));

var enumerateLogs = logs.ToList();
enumerateLogs.Should().NotBeEmpty();
enumerateLogs.Should().HaveCount(inTimeStampCount);
count.Should().Be(inTimeStampCount);
enumerateLogs.Should().OnlyContain(p =>
p.Timestamp.ToUniversalTime() >= firstTimeStamp &&
p.Timestamp.ToUniversalTime() < lastTimeStamp);
}
}
public class DataProviderSearchTest(BaseIntegrationTest instance) : IntegrationSearchTests<BaseIntegrationTest>(instance);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="EphemeralMongo6.runtime.linux-x64" Version="1.0.0" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<PackageReference Include="EphemeralMongo6.runtime.osx-x64" Version="1.0.0" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
<PackageReference Include="EphemeralMongo6.runtime.win-x64" Version="1.1.3" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<PackageReference Include="Serilog.Sinks.MongoDB" Version="5.4.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -24,4 +25,5 @@
<ProjectReference Include="..\..\src\Serilog.Ui.Web\Serilog.Ui.Web.csproj" />
<ProjectReference Include="..\Serilog.Ui.Common.Tests\Serilog.Ui.Common.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ public class BaseIntegrationTest : IIntegrationRunner
{
private bool _disposedValue;

internal BaseServiceBuilder? Builder;
internal MongoDbDataProviderBuilder? Builder;

public Task DisposeAsync() => Task.CompletedTask;

public virtual async Task InitializeAsync()
public virtual Task InitializeAsync()
{
Builder = await MongoDbDataProviderBuilder.Build();
Builder = MongoDbDataProviderBuilder.Build();

return Task.CompletedTask;
}

public IDataProvider GetDataProvider() => Guard.Against.Null(Builder?.Sut);
Expand Down
Loading
Loading