mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Refactor module schema handling and add sync mechanism
Redesigned entity and index management with methods to streamline schema updates and added a sync flag to signal required DB syncs post-build. Enhanced test coverage and functionality for schema modifications, including support for additional fields.
This commit is contained in:
@@ -1,7 +1,53 @@
|
||||
import { describe } from "bun:test";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createApp, registries } from "../../src";
|
||||
import { em, entity, text } from "../../src/data";
|
||||
import { StorageLocalAdapter } from "../../src/media/storage/adapters/StorageLocalAdapter";
|
||||
import { AppMedia } from "../../src/modules";
|
||||
import { moduleTestSuite } from "./module-test-suite";
|
||||
|
||||
describe("AppMedia", () => {
|
||||
moduleTestSuite(AppMedia);
|
||||
|
||||
test("should allow additional fields", async () => {
|
||||
registries.media.register("local", StorageLocalAdapter);
|
||||
|
||||
const app = createApp({
|
||||
initialConfig: {
|
||||
media: {
|
||||
entity_name: "media",
|
||||
enabled: true,
|
||||
adapter: {
|
||||
type: "local",
|
||||
config: {
|
||||
path: "./"
|
||||
}
|
||||
}
|
||||
},
|
||||
data: em({
|
||||
media: entity("media", {
|
||||
additional: text()
|
||||
})
|
||||
}).toJSON()
|
||||
}
|
||||
});
|
||||
|
||||
await app.build();
|
||||
|
||||
const fields = app.modules.em.entity("media").fields.map((f) => f.name);
|
||||
expect(fields).toContain("additional");
|
||||
expect(fields).toEqual([
|
||||
"id",
|
||||
"additional",
|
||||
"path",
|
||||
"folder",
|
||||
"mime_type",
|
||||
"size",
|
||||
"scope",
|
||||
"etag",
|
||||
"modified_at",
|
||||
"reference",
|
||||
"entity_id",
|
||||
"metadata"
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user