forked from gongxuegit/tiku-backend.net
feat: add content navigation and tenant configuration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Tiku.Domain.Content;
|
||||
using Tiku.Domain.QuestionBanks;
|
||||
using Tiku.Infrastructure.Persistence;
|
||||
|
||||
@@ -21,13 +22,46 @@ public sealed class PersistenceModelTests
|
||||
.Select(entity => entity.GetTableName())
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
Assert.Equal(20, tableNames.Count);
|
||||
Assert.Equal(28, tableNames.Count);
|
||||
Assert.Contains("tenants", tableNames);
|
||||
Assert.Contains("tenant_settings", tableNames);
|
||||
Assert.Contains("content_entries", tableNames);
|
||||
Assert.Contains("content_nodes", tableNames);
|
||||
Assert.Contains("question_collections", tableNames);
|
||||
Assert.Contains("practice_blueprints", tableNames);
|
||||
Assert.Contains("questions", tableNames);
|
||||
Assert.Contains("question_versions", tableNames);
|
||||
Assert.Contains("answer_records", tableNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Content_node_path_is_mapped_to_ltree()
|
||||
{
|
||||
using var context = new TikuDbContext(Options);
|
||||
|
||||
var path = context.Model.FindEntityType(typeof(ContentNode))!
|
||||
.FindProperty(nameof(ContentNode.Path))!;
|
||||
|
||||
Assert.Equal("ltree", path.GetColumnType());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Collection_relations_include_tenant_in_foreign_keys()
|
||||
{
|
||||
using var context = new TikuDbContext(Options);
|
||||
|
||||
var foreignKeys = context.Model.FindEntityType(typeof(QuestionCollection))!
|
||||
.GetForeignKeys()
|
||||
.Where(foreignKey => foreignKey.Properties.Count > 1)
|
||||
.Select(foreignKey => foreignKey.Properties
|
||||
.Select(property => property.Name)
|
||||
.ToArray());
|
||||
|
||||
Assert.All(
|
||||
foreignKeys,
|
||||
properties => Assert.Contains("TenantId", properties));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(Question.Tags), "'[]'::jsonb")]
|
||||
public void Question_json_properties_are_mapped_to_jsonb(
|
||||
|
||||
Reference in New Issue
Block a user