forked from xiongyuxing/tiku-backend.net
feat: add pocketbase import audit persistence
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Tiku.Domain.Commerce;
|
||||
using Tiku.Domain.Content;
|
||||
using Tiku.Domain.Growth;
|
||||
using Tiku.Domain.Import;
|
||||
using Tiku.Domain.Learning;
|
||||
using Tiku.Domain.Operations;
|
||||
using Tiku.Domain.Platform;
|
||||
@@ -29,7 +30,7 @@ public sealed class PersistenceModelTests
|
||||
.Select(entity => entity.GetTableName())
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
Assert.Equal(121, tableNames.Count);
|
||||
Assert.Equal(124, tableNames.Count);
|
||||
Assert.Contains("tenants", tableNames);
|
||||
Assert.Contains("tenant_settings", tableNames);
|
||||
Assert.Contains("content_entries", tableNames);
|
||||
@@ -129,6 +130,9 @@ public sealed class PersistenceModelTests
|
||||
Assert.Contains("platform_audit_alerts", tableNames);
|
||||
Assert.Contains("platform_dunning_notification_channels", tableNames);
|
||||
Assert.Contains("platform_dunning_notification_events", tableNames);
|
||||
Assert.Contains("pb_import_runs", tableNames);
|
||||
Assert.Contains("pb_raw_records", tableNames);
|
||||
Assert.Contains("pb_import_issues", tableNames);
|
||||
Assert.Contains("questions", tableNames);
|
||||
Assert.Contains("question_versions", tableNames);
|
||||
Assert.Contains("answer_records", tableNames);
|
||||
@@ -807,4 +811,43 @@ public sealed class PersistenceModelTests
|
||||
.SequenceEqual(propertyNames));
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(PocketBaseImportRun), nameof(PocketBaseImportRun.Stats), "'{}'::jsonb")]
|
||||
[InlineData(typeof(PocketBaseRawRecord), nameof(PocketBaseRawRecord.Record), "'{}'::jsonb")]
|
||||
[InlineData(typeof(PocketBaseRawRecord), nameof(PocketBaseRawRecord.Errors), "'[]'::jsonb")]
|
||||
public void PocketBase_import_json_properties_are_mapped_to_jsonb(
|
||||
Type entityType,
|
||||
string propertyName,
|
||||
string expectedDefaultValueSql)
|
||||
{
|
||||
using var context = new TikuDbContext(Options);
|
||||
|
||||
var property = context.Model.FindEntityType(entityType)!
|
||||
.FindProperty(propertyName)!;
|
||||
|
||||
Assert.Equal("jsonb", property.GetColumnType());
|
||||
Assert.Equal(expectedDefaultValueSql, property.GetDefaultValueSql());
|
||||
Assert.Equal(typeof(System.Text.Json.JsonElement), property.ClrType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PocketBase_import_raw_records_keep_legacy_identity_in_primary_key()
|
||||
{
|
||||
using var context = new TikuDbContext(Options);
|
||||
|
||||
var keyProperties = context.Model.FindEntityType(typeof(PocketBaseRawRecord))!
|
||||
.FindPrimaryKey()!
|
||||
.Properties
|
||||
.Select(property => property.Name)
|
||||
.ToArray();
|
||||
|
||||
Assert.Equal(
|
||||
[
|
||||
nameof(PocketBaseRawRecord.RunId),
|
||||
nameof(PocketBaseRawRecord.CollectionName),
|
||||
nameof(PocketBaseRawRecord.LegacyId)
|
||||
],
|
||||
keyProperties);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user