Skip to content

Commit dcf6be8

Browse files
committed
GitHub CI: исправление на release + документация по тестам и нейминг
1 parent a083e6b commit dcf6be8

24 files changed

+63
-45
lines changed

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323
- name: Restore dependencies
2424
run: dotnet restore
2525
- name: Build
26-
run: dotnet build --no-restore
26+
run: dotnet build --no-restore -c Release
2727
- name: Test
28-
run: dotnet test --no-build --verbosity normal
28+
run: dotnet test --no-build --verbosity normal -c Release

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
- добавлены скрипты для npm
99
- проект фронта убран из решения, редуцирован до файлов и разложен по виртуальным папкам (временный вариант)
1010
* upd: начата чистка кода и изменение именований, в т.ч. контекста EF
11+
12+
* fix: исправлен тестовый db-репозиторий с моком IQueryable
13+
* upd: добавлено использование SQLite для запуска интеграционных тестов и пример интеграционника

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.NET 7 | TypeScript React | MSTest | Docker
88
```
99
* ```bash
10-
MySQL | EF
10+
MySQL | SQlLite | EF
1111
```
1212
---------------------------------------------
1313

@@ -45,6 +45,7 @@
4545
- для накатки базы из дампа скопируйте файл с дампом бд, именуемый `backup_9.txt`, в папку `Rsse.Base/ClientApp/build` перед сборкой docker-образа.
4646
После подъёма контейнера запустите команду **Каталог>Restore** в меню сервиса.
4747
- для демонстрации функционала в VCS закоммитан файл с каталогом из 915 песен.
48+
- для запуска интеграционных тестов поднимается тестовая SQLite бд (в файле)
4849
* API
4950
- под development доступна ручка **/swagger/v1/swagger.json**
5051
- также в **Rsse.Base/Controller** закоммитан **api.v5.json**

ReducedSetSearchEngineService.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "front.scripts", "front.scri
5555
src\Rsse.Front\start.bat = src\Rsse.Front\start.bat
5656
EndProjectSection
5757
EndProject
58+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".workflow", ".workflow", "{783F77EB-C548-44FA-9E9C-03B9185033F1}"
59+
ProjectSection(SolutionItems) = preProject
60+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
61+
EndProjectSection
62+
EndProject
5863
Global
5964
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6065
Debug|Any CPU = Debug|Any CPU

src/Rsse.Data/Data/Context/CatalogContext.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ public CatalogContext(DbContextOptions<CatalogContext> option) : base(option)
3737
switch (Database.ProviderName)
3838
{
3939
case "Pomelo.EntityFrameworkCore.MySql":
40-
if (created) Database.ExecuteSqlRaw(MySqlScripts.CreateGenresScript);
40+
if (created) Database.ExecuteSqlRaw(MySqlScript.CreateGenresScript);
4141
break;
4242

4343
case "Microsoft.EntityFrameworkCore.SqlServer":
44-
if (created) Database.ExecuteSqlRaw(MsSqlScripts.CreateGenresScript);
44+
if (created) Database.ExecuteSqlRaw(MsSqlScript.CreateGenresScript);
4545
break;
4646

47+
// данный провайдер используется при запуске интеграционных тестов:
4748
case "Microsoft.EntityFrameworkCore.Sqlite":
4849
// можно инициализировать тестовую базу на каждый вызов контекста:
49-
if (created) Database.ExecuteSqlRaw(SqlLiteScripts.CreateGenresScript);
50+
if (created) Database.ExecuteSqlRaw(SQLiteIntegrationTestScript.CreateGenresScript);
5051
break;
5152

5253
default:

src/Rsse.Data/Data/Repository/Scripts/MsSqlScripts.cs renamed to src/Rsse.Data/Data/Repository/Scripts/MsSqlScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace SearchEngine.Data.Repository.Scripts;
22

3-
public static class MsSqlScripts
3+
public static class MsSqlScript
44
{
55
public const string CreateGenresScript = """
66
SET IDENTITY_INSERT [dbo].[Genre] ON

src/Rsse.Data/Data/Repository/Scripts/MySqlScripts.cs renamed to src/Rsse.Data/Data/Repository/Scripts/MySqlScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace SearchEngine.Data.Repository.Scripts;
44

55
// [TODO] разберись с индексами: индекс по genre, genre c id добавляются в алфавитном порядке столбца genre
6-
public static class MySqlScripts
6+
public static class MySqlScript
77
{
88
public const string CreateGenresScript = $"""
99
INSERT Users(Email, Password) VALUES

src/Rsse.Data/Data/Repository/Scripts/SqlLiteScripts.cs renamed to src/Rsse.Data/Data/Repository/Scripts/SQLiteIntegrationTestScript.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
namespace SearchEngine.Data.Repository.Scripts;
22

3-
public static class SqlLiteScripts
3+
/// <summary>
4+
/// Скрипт инициализируется при запуске интеграционных тестов
5+
/// Ссылка на особенности SQLite: https://www.sqlite.org/lang.html
6+
/// </summary>
7+
// ReSharper disable once InconsistentNaming
8+
public static class SQLiteIntegrationTestScript
49
{
510
public const string CreateGenresScript = """
611
INSERT INTO [Genre] ([GenreID], [Genre]) VALUES (1, 'Авторские');

tests/Rsse.Tests/Integration/CustomWebAppFactory.cs renamed to tests/Rsse.Tests/Integrations/Infra/CustomWebAppFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Microsoft.AspNetCore.Mvc.Testing;
44
using Microsoft.Extensions.Hosting;
55

6-
namespace SearchEngine.Tests.Integration;
6+
namespace SearchEngine.Tests.Integrations.Infra;
77

88
public class CustomWebAppFactory : WebApplicationFactory<IntegrationStartup>
99
{

tests/Rsse.Tests/Integration/IntegrationStartup.cs renamed to tests/Rsse.Tests/Integrations/Infra/IntegrationStartup.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
using SearchEngine.Data.Repository.Contracts;
1111
using SearchEngine.Infrastructure.Tokenizer;
1212
using SearchEngine.Infrastructure.Tokenizer.Contracts;
13-
using SearchEngine.Tests.Infrastructure;
13+
using SearchEngine.Tests.Units.Mocks;
1414

15-
namespace SearchEngine.Tests.Integration;
15+
namespace SearchEngine.Tests.Integrations.Infra;
1616

17+
/// <summary>
18+
/// При конфинурации запуска используется SQLite, информация по данной бд: https://www.sqlite.org/lang.html
19+
/// </summary>
1720
public class IntegrationStartup
1821
{
1922
public static void ConfigureServices(IServiceCollection services)
2023
{
2124
services
2225
.AddControllers()
23-
// разберись почему требуется этот метод:
26+
// I. разберись почему требуется этот метод:
2427
// https://andrewlock.net/when-asp-net-core-cant-find-your-controller-debugging-application-parts/
2528
.AddApplicationPart(typeof(ReadController).Assembly);
2629

@@ -31,14 +34,13 @@ public static void ConfigureServices(IServiceCollection services)
3134
services.AddTransient<ITokenizerProcessor, TokenizerProcessor>();
3235
services.AddTransient<ITokenizerService, TokenizerService>();
3336

34-
// III. SQLITE: https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli
35-
// возможно, что данная папка есть только в windows:
37+
// II. SQLite: https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli
38+
// проверено на Windows и на Ubuntu (в GitHub Actions CI):
3639

3740
const Environment.SpecialFolder folder = Environment.SpecialFolder.LocalApplicationData;
3841
var path = Environment.GetFolderPath(folder);
3942
var dbPath = System.IO.Path.Join(path, "testing-2.db");
4043
var connectionString = $"Data Source={dbPath}";
41-
// https://www.sqlite.org/lang.html
4244

4345
services.AddDbContext<CatalogContext>(options => options.UseSqlite(connectionString));
4446
}

0 commit comments

Comments
 (0)