Refactor SQLite Database Provider
- Removed unused classes and files related to SQLite database provider, including SqliteDesignTimeJellyfinDbFactory, ModelBuilderExtensions, PragmaConnectionInterceptor, AssemblyInfo, SqliteDatabaseProvider, DateTimeKindValueConverter. - Updated tests to remove dependencies on removed classes and adjusted mocking for configuration sections. - Added Microsoft.EntityFrameworkCore.Sqlite package reference to test project. - Improved string handling in tests for better consistency and clarity. - Refactored logging methods in JellyfinApplicationFactory for better readability and maintainability.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
#pragma warning disable CA1308 // Normalize strings to uppercase
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
{
|
||||
using System;
|
||||
@@ -28,11 +30,11 @@ namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
|
||||
var configSection = new Mock<IConfigurationSection>();
|
||||
configSection
|
||||
.SetupGet(x => x[It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)])
|
||||
.SetupGet(x => x[It.IsAny<string>()])
|
||||
.Returns("0");
|
||||
var config = new Mock<IConfiguration>();
|
||||
config
|
||||
.Setup(x => x.GetSection(It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)))
|
||||
.Setup(x => x.GetSection(It.IsAny<string>()))
|
||||
.Returns(configSection.Object);
|
||||
|
||||
_fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
|
||||
var configSection = new Mock<IConfigurationSection>();
|
||||
configSection
|
||||
.SetupGet(x => x[It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)])
|
||||
.SetupGet(x => x[It.IsAny<string>()])
|
||||
.Returns("0");
|
||||
var config = new Mock<IConfiguration>();
|
||||
config
|
||||
.Setup(x => x.GetSection(It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)))
|
||||
.Setup(x => x.GetSection(It.IsAny<string>()))
|
||||
.Returns(configSection.Object);
|
||||
|
||||
_fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
#pragma warning disable CA1517 // Do not use overloads of StartsWith/EndsWith with char when multiple characters are expected
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.HttpServer
|
||||
{
|
||||
using System;
|
||||
@@ -54,7 +56,7 @@ namespace Jellyfin.Server.Implementations.Tests.HttpServer
|
||||
|
||||
internal sealed class BufferSegment : ReadOnlySequenceSegment<byte>
|
||||
{
|
||||
public BufferSegment(Memory<byte> memory)
|
||||
public BufferSegment(ReadOnlyMemory<byte> memory)
|
||||
{
|
||||
Memory = memory;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Database.Implementations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Database.Implementations.Locking;
|
||||
using Jellyfin.Server.Implementations.Item;
|
||||
@@ -116,7 +115,7 @@ public class BaseItemRepositoryTests
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
var placeholder = await context.BaseItems.SingleAsync(e => e.Id == BaseItemRepository.PlaceholderId);
|
||||
var placeholder = await context.BaseItems.SingleAsync(e => e.Id.Equals(BaseItemRepository.PlaceholderId));
|
||||
context.BaseItems.Remove(placeholder);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
@@ -133,11 +132,11 @@ public class BaseItemRepositoryTests
|
||||
await repository.DeleteItemAsync([itemId], CancellationToken.None);
|
||||
|
||||
await using var verificationContext = await dbFactory.CreateDbContextAsync(CancellationToken.None);
|
||||
var recreatedPlaceholder = await verificationContext.BaseItems.SingleOrDefaultAsync(e => e.Id == BaseItemRepository.PlaceholderId);
|
||||
var recreatedPlaceholder = await verificationContext.BaseItems.SingleOrDefaultAsync(e => e.Id.Equals(BaseItemRepository.PlaceholderId));
|
||||
var detachedUserData = await verificationContext.UserData.SingleAsync();
|
||||
|
||||
Assert.NotNull(recreatedPlaceholder);
|
||||
Assert.Null(await verificationContext.BaseItems.SingleOrDefaultAsync(e => e.Id == itemId));
|
||||
Assert.Null(await verificationContext.BaseItems.SingleOrDefaultAsync(e => e.Id.Equals(itemId)));
|
||||
Assert.Equal(BaseItemRepository.PlaceholderId, detachedUserData.ItemId);
|
||||
Assert.NotNull(detachedUserData.RetentionDate);
|
||||
}
|
||||
|
||||
+1
@@ -22,6 +22,7 @@
|
||||
<PackageReference Include="AutoFixture" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" />
|
||||
<PackageReference Include="Jellyfin.Sdk" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="xunit" />
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AudioResolverTests
|
||||
var childrenMetadata = children.Select(name => new FileSystemMetadata
|
||||
{
|
||||
FullName = parent + "/" + name,
|
||||
IsDirectory = name.EndsWith("/", StringComparison.OrdinalIgnoreCase)
|
||||
IsDirectory = name.EndsWith('/', StringComparison.OrdinalIgnoreCase)
|
||||
}).ToArray();
|
||||
|
||||
var resolver = new AudioResolver(_namingOptions);
|
||||
|
||||
Reference in New Issue
Block a user