Projects STRLCPY dolt Commits 8398fa40
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/mikro-orm/README.md
     1 +# Mikro-ORM Smoke Test
     2 + 
     3 +The `index.ts` file is the main entry point and will insert a new record into the database, then load it, print
     4 +success, and exit with a zero exit code. If any errors are encountered, they are logged, and the process exits with a
     5 +non-zero exit code.
     6 + 
     7 +To run this smoke test project:
     8 +1. Run `npm install` command
     9 +2. Run `npm start` command
     10 + 
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/mikro-orm/package.json
     1 +{
     2 + "name": "mikro-orm-smoketest",
     3 + "version": "0.0.1",
     4 + "description": "DoltDB smoke test for Mikro-ORM integration",
     5 + "type": "commonjs",
     6 + "scripts": {
     7 + "start": "ts-node src/index.ts",
     8 + "mikro-orm": "mikro-orm-ts-node-commonjs"
     9 + },
     10 + "devDependencies": {
     11 + "ts-node": "^10.7.0",
     12 + "@types/node": "^16.11.10",
     13 + "typescript": "^4.5.2"
     14 + },
     15 + "dependencies": {
     16 + "@mikro-orm/core": "^5.0.3",
     17 + "@mikro-orm/mysql": "^5.0.3",
     18 + "mysql": "^2.14.1"
     19 + }
     20 +}
     21 + 
     22 + 
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/mikro-orm/src/entity/User.ts
     1 +import { Entity, PrimaryKey, Property } from "@mikro-orm/core";
     2 + 
     3 +@Entity()
     4 +export class User {
     5 + @PrimaryKey()
     6 + id!: number;
     7 + 
     8 + @Property()
     9 + firstName!: string;
     10 + 
     11 + @Property()
     12 + lastName!: string;
     13 + 
     14 + @Property()
     15 + age!: number;
     16 + 
     17 + constructor(firstName: string, lastName: string, age: number) {
     18 + this.firstName = firstName;
     19 + this.lastName = lastName;
     20 + this.age = age;
     21 + }
     22 +}
     23 + 
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/mikro-orm/src/index.ts
     1 +import { MikroORM } from "@mikro-orm/core";
     2 +import { MySqlDriver } from '@mikro-orm/mysql';
     3 +import { User } from "./entity/User";
     4 + 
     5 +async function connectAndGetOrm() {
     6 + const orm = await MikroORM.init<MySqlDriver>({
     7 + entities: [User],
     8 + type: "mysql",
     9 + clientUrl: "mysql://localhost:3306",
     10 + dbName: "dolt",
     11 + user: "dolt",
     12 + password: "",
     13 + persistOnCreate: true,
     14 + });
     15 + 
     16 + return orm;
     17 +}
     18 + 
     19 +connectAndGetOrm().then(async orm => {
     20 + console.log("Connected");
     21 + const em = orm.em.fork();
     22 + 
     23 + // this creates the tables if not exist
     24 + const generator = orm.getSchemaGenerator();
     25 + await generator.updateSchema();
     26 + 
     27 + console.log("Inserting a new user into the database...")
     28 + const user = new User("Timber", "Saw", 25)
     29 + await em.persistAndFlush(user)
     30 + console.log("Saved a new user with id: " + user.id)
     31 + 
     32 + console.log("Loading users from the database...")
     33 + const users = await em.findOne(User, 1)
     34 + console.log("Loaded users: ", users)
     35 + 
     36 + orm.close();
     37 + console.log("Smoke test passed!")
     38 + process.exit(0)
     39 +}).catch(error => {
     40 + console.log(error)
     41 + console.log("Smoke test failed!")
     42 + process.exit(1)
     43 +});
     44 + 
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/mikro-orm/tsconfig.json
     1 +{
     2 + "compilerOptions": {
     3 + "module": "commonjs",
     4 + "declaration": true,
     5 + "removeComments": true,
     6 + "emitDecoratorMetadata": true,
     7 + "esModuleInterop": true,
     8 + "experimentalDecorators": true,
     9 + "target": "es2017",
     10 + "outDir": "./dist",
     11 + "baseUrl": "./src",
     12 + "incremental": true,
     13 + }
     14 +}
     15 + 
  • ■ ■ ■ ■ ■ ■
    integration-tests/orm-tests/orm-tests.bats
    skipped 54 lines
    55 55   npx -c "prisma migrate dev --name init"
    56 56  }
    57 57   
    58  -# Prisma is an ORM for Node/TypeScript applications. This test checks out the Peewee test suite
     58 +# Prisma is an ORM for Node/TypeScript applications. This test checks out the Prisma test suite
    59 59  # and runs it against Dolt.
    60 60  @test "Prisma ORM test suite" {
    61 61   skip "Not implemented yet"
    skipped 11 lines
    73 73   mysql --protocol TCP -u dolt -e "create database dolt;"
    74 74   
    75 75   cd typeorm
     76 + npm install
     77 + npm start
     78 +}
     79 + 
     80 +# MikroORM is an ORM for Node/TypeScript applications. This is a simple smoke test to make sure
     81 +# Dolt can support the most basic MikroORM operations.
     82 +@test "MikroORM smoke test" {
     83 + mysql --protocol TCP -u dolt -e "create database dolt;"
     84 + 
     85 + cd mikro-orm
    76 86   npm install
    77 87   npm start
    78 88  }
    skipped 6 lines
Please wait...
Page is in error, reload to recover