Fixing seasons tests and running tests in parallel

This commit is contained in:
Zoe Roux 2021-06-21 21:59:54 +02:00
parent bd82fbfb2c
commit d7d40aef24
18 changed files with 163 additions and 37 deletions

View File

@ -20,7 +20,7 @@ namespace Kyoo.Models
public string Slug public string Slug
{ {
get => GetSlug(ShowSlug, SeasonNumber, EpisodeNumber, AbsoluteNumber); get => GetSlug(ShowSlug, SeasonNumber, EpisodeNumber, AbsoluteNumber);
set [UsedImplicitly] private set
{ {
Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d*)e(?<episode>\d*)"); Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d*)e(?<episode>\d*)");

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Kyoo.Controllers; using Kyoo.Controllers;
using Kyoo.Models.Attributes; using Kyoo.Models.Attributes;
@ -18,7 +19,7 @@ namespace Kyoo.Models
public string Slug public string Slug
{ {
get => $"{ShowSlug}-s{SeasonNumber}"; get => $"{ShowSlug}-s{SeasonNumber}";
set [UsedImplicitly] private set
{ {
Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d*)"); Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d*)");

View File

@ -2,6 +2,7 @@
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Kyoo.Models.Attributes; using Kyoo.Models.Attributes;
namespace Kyoo.Models namespace Kyoo.Models
@ -48,7 +49,7 @@ namespace Kyoo.Models
}; };
return $"{EpisodeSlug}.{type}{Language}{index}{(IsForced ? "-forced" : "")}{codec}"; return $"{EpisodeSlug}.{type}{Language}{index}{(IsForced ? "-forced" : "")}{codec}";
} }
set [UsedImplicitly] private set
{ {
Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d+)e(?<episode>\d+)" Match match = Regex.Match(value, @"(?<show>.*)-s(?<season>\d+)e(?<episode>\d+)"
+ @"(\.(?<type>\w*))?\.(?<language>.{0,3})(?<forced>-forced)?(\..\w)?"); + @"(\.(?<type>\w*))?\.(?<language>.{0,3})(?<forced>-forced)?(\..\w)?");

View File

@ -302,15 +302,34 @@ namespace Kyoo
modelBuilder.Entity<Season>() modelBuilder.Entity<Season>()
.HasIndex(x => new {x.ShowID, x.SeasonNumber}) .HasIndex(x => new {x.ShowID, x.SeasonNumber})
.IsUnique(); .IsUnique();
modelBuilder.Entity<Season>()
.HasIndex(x => x.Slug)
.IsUnique();
modelBuilder.Entity<Episode>() modelBuilder.Entity<Episode>()
.HasIndex(x => new {x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber}) .HasIndex(x => new {x.ShowID, x.SeasonNumber, x.EpisodeNumber, x.AbsoluteNumber})
.IsUnique(); .IsUnique();
modelBuilder.Entity<Episode>()
.HasIndex(x => x.Slug)
.IsUnique();
modelBuilder.Entity<Track>() modelBuilder.Entity<Track>()
.HasIndex(x => new {x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced}) .HasIndex(x => new {x.EpisodeID, x.Type, x.Language, x.TrackIndex, x.IsForced})
.IsUnique(); .IsUnique();
modelBuilder.Entity<Track>()
.HasIndex(x => x.Slug)
.IsUnique();
modelBuilder.Entity<User>() modelBuilder.Entity<User>()
.HasIndex(x => x.Slug) .HasIndex(x => x.Slug)
.IsUnique(); .IsUnique();
modelBuilder.Entity<Season>()
.Property(x => x.Slug)
.ValueGeneratedOnAddOrUpdate();
modelBuilder.Entity<Episode>()
.Property(x => x.Slug)
.ValueGeneratedOnAddOrUpdate();
modelBuilder.Entity<Track>()
.Property(x => x.Slug)
.ValueGeneratedOnAddOrUpdate();
} }
/// <summary> /// <summary>

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Kyoo.Postgresql.Migrations namespace Kyoo.Postgresql.Migrations
{ {
[DbContext(typeof(PostgresContext))] [DbContext(typeof(PostgresContext))]
[Migration("20210619153358_Initial")] [Migration("20210621175845_Initial")]
partial class Initial partial class Initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -86,6 +86,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -98,6 +99,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -432,6 +436,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -442,6 +447,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -559,6 +567,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Title") b.Property<string>("Title")
@ -572,6 +581,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -564,6 +564,12 @@ namespace Kyoo.Postgresql.Migrations
columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" }, columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Episodes_Slug",
table: "Episodes",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Genres_Slug", name: "IX_Genres_Slug",
table: "Genres", table: "Genres",
@ -654,6 +660,12 @@ namespace Kyoo.Postgresql.Migrations
columns: new[] { "ShowID", "SeasonNumber" }, columns: new[] { "ShowID", "SeasonNumber" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Seasons_Slug",
table: "Seasons",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Shows_Slug", name: "IX_Shows_Slug",
table: "Shows", table: "Shows",
@ -677,6 +689,12 @@ namespace Kyoo.Postgresql.Migrations
columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" }, columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Tracks_Slug",
table: "Tracks",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Users_Slug", name: "IX_Users_Slug",
table: "Users", table: "Users",

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Kyoo.Postgresql.Migrations namespace Kyoo.Postgresql.Migrations
{ {
[DbContext(typeof(PostgresContext))] [DbContext(typeof(PostgresContext))]
[Migration("20210620120239_Triggers")] [Migration("20210621175855_Triggers")]
partial class Triggers partial class Triggers
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -86,6 +86,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -98,6 +99,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -432,6 +436,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -442,6 +447,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -559,6 +567,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Title") b.Property<string>("Title")
@ -572,6 +581,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -2,10 +2,10 @@
namespace Kyoo.Postgresql.Migrations namespace Kyoo.Postgresql.Migrations
{ {
public partial class Triggers : Migration public partial class Triggers : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.Sql(@" migrationBuilder.Sql(@"
CREATE FUNCTION season_slug_update() CREATE FUNCTION season_slug_update()
RETURNS TRIGGER RETURNS TRIGGER
@ -14,13 +14,9 @@ namespace Kyoo.Postgresql.Migrations
BEGIN BEGIN
NEW.""Slug"" := CONCAT( NEW.""Slug"" := CONCAT(
(SELECT ""Slug"" FROM ""Shows"" WHERE ""ID"" = NEW.""ShowID""), (SELECT ""Slug"" FROM ""Shows"" WHERE ""ID"" = NEW.""ShowID""),
NEW.""ShowID"",
OLD.""SeasonNumber"",
NEW.""SeasonNumber"",
'-s', '-s',
NEW.""SeasonNumber"" NEW.""SeasonNumber""
); );
NEW.""Poster"" := 'NICE';
RETURN NEW; RETURN NEW;
END END
$$;"); $$;");
@ -41,17 +37,17 @@ namespace Kyoo.Postgresql.Migrations
END END
$$;"); $$;");
migrationBuilder.Sql(@" migrationBuilder.Sql(@"
CREATE TRIGGER ""ShowSlug"" AFTER UPDATE OF ""Slug"" ON ""Shows"" CREATE TRIGGER ""ShowSlug"" AFTER UPDATE OF ""Slug"" ON ""Shows""
FOR EACH ROW EXECUTE PROCEDURE show_slug_update();"); FOR EACH ROW EXECUTE PROCEDURE show_slug_update();");
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.Sql(@"DROP FUNCTION ""season_slug_update"";"); migrationBuilder.Sql(@"DROP FUNCTION ""season_slug_update"";");
migrationBuilder.Sql(@"DROP TRIGGER ""SeasonSlug"";"); migrationBuilder.Sql(@"DROP TRIGGER ""SeasonSlug"";");
migrationBuilder.Sql(@"DROP FUNCTION ""show_slug_update"";"); migrationBuilder.Sql(@"DROP FUNCTION ""show_slug_update"";");
migrationBuilder.Sql(@"DROP TRIGGER ""ShowSlug"";"); migrationBuilder.Sql(@"DROP TRIGGER ""ShowSlug"";");
} }
} }
} }

View File

@ -84,6 +84,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -96,6 +97,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -430,6 +434,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -440,6 +445,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -557,6 +565,7 @@ namespace Kyoo.Postgresql.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Title") b.Property<string>("Title")
@ -570,6 +579,9 @@ namespace Kyoo.Postgresql.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.SqLite.Migrations namespace Kyoo.SqLite.Migrations
{ {
[DbContext(typeof(SqLiteContext))] [DbContext(typeof(SqLiteContext))]
[Migration("20210619154617_Initial")] [Migration("20210621175330_Initial")]
partial class Initial partial class Initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -76,6 +76,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -88,6 +89,9 @@ namespace Kyoo.SqLite.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -416,6 +420,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -426,6 +431,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -540,6 +548,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
@ -553,6 +562,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -556,6 +556,12 @@ namespace Kyoo.SqLite.Migrations
columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" }, columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Episodes_Slug",
table: "Episodes",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Genres_Slug", name: "IX_Genres_Slug",
table: "Genres", table: "Genres",
@ -646,6 +652,12 @@ namespace Kyoo.SqLite.Migrations
columns: new[] { "ShowID", "SeasonNumber" }, columns: new[] { "ShowID", "SeasonNumber" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Seasons_Slug",
table: "Seasons",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Shows_Slug", name: "IX_Shows_Slug",
table: "Shows", table: "Shows",
@ -669,6 +681,12 @@ namespace Kyoo.SqLite.Migrations
columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" }, columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_Tracks_Slug",
table: "Tracks",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Users_Slug", name: "IX_Users_Slug",
table: "Users", table: "Users",

View File

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kyoo.SqLite.Migrations namespace Kyoo.SqLite.Migrations
{ {
[DbContext(typeof(SqLiteContext))] [DbContext(typeof(SqLiteContext))]
[Migration("20210619154654_Triggers")] [Migration("20210621175342_Triggers")]
partial class Triggers partial class Triggers
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -76,6 +76,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -88,6 +89,9 @@ namespace Kyoo.SqLite.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -416,6 +420,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -426,6 +431,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -540,6 +548,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
@ -553,6 +562,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -74,6 +74,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Thumb") b.Property<string>("Thumb")
@ -86,6 +87,9 @@ namespace Kyoo.SqLite.Migrations
b.HasIndex("SeasonID"); b.HasIndex("SeasonID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber") b.HasIndex("ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber")
.IsUnique(); .IsUnique();
@ -414,6 +418,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<DateTime?>("StartDate") b.Property<DateTime?>("StartDate")
@ -424,6 +429,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("ShowID", "SeasonNumber") b.HasIndex("ShowID", "SeasonNumber")
.IsUnique(); .IsUnique();
@ -538,6 +546,7 @@ namespace Kyoo.SqLite.Migrations
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Slug") b.Property<string>("Slug")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
@ -551,6 +560,9 @@ namespace Kyoo.SqLite.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced") b.HasIndex("EpisodeID", "Type", "Language", "TrackIndex", "IsForced")
.IsUnique(); .IsUnique();

View File

@ -16,6 +16,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Xunit.Extensions.Ordering" Version="1.4.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

View File

@ -2,6 +2,7 @@ using System.Threading.Tasks;
using Kyoo.Controllers; using Kyoo.Controllers;
using Kyoo.Models; using Kyoo.Models;
using Xunit; using Xunit;
using Xunit.Extensions.Ordering;
namespace Kyoo.Tests.SpecificTests namespace Kyoo.Tests.SpecificTests
{ {
@ -12,8 +13,8 @@ namespace Kyoo.Tests.SpecificTests
{ } { }
} }
[Collection(nameof(Postgresql))]
public class PostgresSeasonTests : SeasonTests public class PostgresSeasonTests : SeasonTests, IAssemblyFixture<PostgresFixture>
{ {
public PostgresSeasonTests(PostgresFixture postgres) public PostgresSeasonTests(PostgresFixture postgres)
: base(new RepositoryActivator(postgres)) : base(new RepositoryActivator(postgres))
@ -67,7 +68,6 @@ namespace Kyoo.Tests.SpecificTests
ShowID = TestSample.Get<Show>().ID, ShowID = TestSample.Get<Show>().ID,
SeasonNumber = 2 SeasonNumber = 2
}); });
Assert.Equal($"{TestSample.Get<Show>().Slug}-s2_NICE", season.Slug + "_" + season.Poster);
Assert.Equal($"{TestSample.Get<Show>().Slug}-s2", season.Slug); Assert.Equal($"{TestSample.Get<Show>().Slug}-s2", season.Slug);
} }
} }

View File

@ -6,6 +6,7 @@ using Kyoo.Controllers;
using Kyoo.Models; using Kyoo.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Xunit; using Xunit;
using Xunit.Extensions.Ordering;
namespace Kyoo.Tests.SpecificTests namespace Kyoo.Tests.SpecificTests
{ {
@ -16,8 +17,7 @@ namespace Kyoo.Tests.SpecificTests
{ } { }
} }
[Collection(nameof(Postgresql))] public class PostgresShowTests : ShowTests, IAssemblyFixture<PostgresFixture>
public class PostgresShowTests : ShowTests
{ {
public PostgresShowTests(PostgresFixture postgres) public PostgresShowTests(PostgresFixture postgres)
: base(new RepositoryActivator(postgres)) : base(new RepositoryActivator(postgres))
@ -283,6 +283,5 @@ namespace Kyoo.Tests.SpecificTests
Assert.Equal(0, await Repositories.LibraryManager.SeasonRepository.GetCount()); Assert.Equal(0, await Repositories.LibraryManager.SeasonRepository.GetCount());
Assert.Equal(0, await Repositories.LibraryManager.EpisodeRepository.GetCount()); Assert.Equal(0, await Repositories.LibraryManager.EpisodeRepository.GetCount());
} }
} }
} }

View File

@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging;
using Npgsql; using Npgsql;
using Xunit; using Xunit;
[assembly: TestFramework("Xunit.Extensions.Ordering.TestFramework", "Xunit.Extensions.Ordering")]
namespace Kyoo.Tests namespace Kyoo.Tests
{ {
public sealed class SqLiteTestContext : TestContext public sealed class SqLiteTestContext : TestContext
@ -29,6 +31,9 @@ namespace Kyoo.Tests
_context = new DbContextOptionsBuilder<DatabaseContext>() _context = new DbContextOptionsBuilder<DatabaseContext>()
.UseSqlite(_connection) .UseSqlite(_connection)
.UseLoggerFactory(LoggerFactory.Create(x => x.AddConsole()))
.EnableSensitiveDataLogging()
.EnableDetailedErrors()
.Options; .Options;
using DatabaseContext context = New(); using DatabaseContext context = New();
@ -52,10 +57,6 @@ namespace Kyoo.Tests
} }
} }
[CollectionDefinition(nameof(Postgresql))]
public class PostgresCollection : ICollectionFixture<PostgresFixture>
{}
public sealed class PostgresFixture : IDisposable public sealed class PostgresFixture : IDisposable
{ {
private readonly DbContextOptions<DatabaseContext> _options; private readonly DbContextOptions<DatabaseContext> _options;