Files
Oleksandr Bezdieniezhnykh 6b2c2d998e [AZ-577] [AZ-578] [AZ-579] [AZ-580] Implement E2E test batch 2
Adds 26 blackbox tests (FT-P-01..18, FT-N-01..08) covering full AC
matrices for Vehicles/Missions/Waypoints/Health/Errors. Three
spec-vs-code carry-forwards documented in batch_02_report.md and
pinned with [Trait("carry_forward", ...)].

Shared scaffolding: ApiDtos.cs, AssertProblemEnvelopeAsync helper,
Seeds.cs, StubSchema.cs, CascadeF3/F4 fixtures, PostgresStopStart
fixture (gated by COMPOSE_RESTART_ENABLED). Removes the 4 placeholder
Sanity.cs files (now superseded). docker-compose.test.yml gains the
expected_results volume mount + FIXTURE_SQL_DIR for the consumer.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-15 08:28:37 +03:00

46 lines
1.6 KiB
C#

using Npgsql;
namespace Azaion.Missions.E2E.Fixtures;
/// <summary>
/// Creates the borrowed-schema stub tables (media, annotations, detection)
/// required by the cascade-delete fixtures. The migrator (<c>DatabaseMigrator</c>)
/// only owns the missions/vehicles/waypoints/map_objects tables; media,
/// annotations, and detection are owned by sibling services in production
/// (out of scope for this repo per
/// _docs/02_document/tests/environment.md). The cascade walk in
/// <c>MissionService.DeleteMission</c> still references them, so tests must
/// supply their schema via side-channel.
/// </summary>
/// <remarks>
/// Idempotent — every statement is <c>CREATE … IF NOT EXISTS</c>.
/// Column shapes match the LinqToDB entities (<c>Database/Entities/Media.cs</c>,
/// <c>Database/Entities/Annotation.cs</c>, <c>Database/Entities/Detection.cs</c>).
/// </remarks>
public static class StubSchema
{
public static void EnsureCreated()
{
using var conn = new NpgsqlConnection(TestEnvironment.DbSideChannel);
conn.Open();
using var cmd = conn.CreateCommand();
cmd.CommandText = """
CREATE TABLE IF NOT EXISTS media (
id TEXT PRIMARY KEY,
waypoint_id UUID
);
CREATE TABLE IF NOT EXISTS annotations (
id TEXT PRIMARY KEY,
media_id TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS detection (
id UUID PRIMARY KEY,
annotation_id TEXT NOT NULL
);
""";
cmd.ExecuteNonQuery();
}
}