- Removed the `plugins.constants.ts` file as it was no longer needed. - Updated the `vm.class.ts` to improve result handling and logging. - Introduced `vm.constants.ts` to manage registered plugins and modules. - Simplified the test payload in `case1-payload.js` by removing unnecessary insert logic. - Enhanced `case1.ts` to include database and migration setup, improving test clarity. - Deleted unused functions for adding modules and plugins, streamlining the codebase.
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import createMigration from "../functions/createMigration";
|
|
import createDatabase from "../functions/createDatabase";
|
|
import createDatabaseNode from "../functions/createDatabaseNode";
|
|
import createProject from "../functions/createProject";
|
|
import createQuery from "../functions/createQuery";
|
|
import databaseMigrationUp from "../functions/databaseMigrationUp";
|
|
import runQuery from "../functions/runQuery";
|
|
import * as fs from "fs";
|
|
import * as path from "path";
|
|
|
|
(async () => {
|
|
try {
|
|
const node = await createDatabaseNode("localhost", 3306, "root", "root");
|
|
|
|
console.log("Database node created:", node);
|
|
|
|
const project = await createProject("Test Project");
|
|
|
|
console.log("Project created:", project);
|
|
|
|
const db = await createDatabase(project.id, node.id);
|
|
|
|
console.log("Database created:", db);
|
|
|
|
const migration = await createMigration(
|
|
db.id,
|
|
"CREATE TABLE `test` (id INT AUTO_INCREMENT PRIMARY KEY, col1 VARCHAR(255))",
|
|
"DROP TABLE `test`"
|
|
);
|
|
|
|
console.log("Migration created:", migration);
|
|
|
|
const migrationResult = await databaseMigrationUp(db.id);
|
|
|
|
console.log("Migrations applied:", migrationResult);
|
|
|
|
const payloadPath = path.join(__dirname, "case1-payload.js");
|
|
const query = await createQuery(
|
|
project,
|
|
fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
|
);
|
|
|
|
console.log(query);
|
|
|
|
const result = await runQuery(query.id, { id: 1 });
|
|
|
|
console.log("Query Result:", result.data);
|
|
} catch (error) {
|
|
console.error("Error during test execution");
|
|
}
|
|
})();
|