mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-20 12:10:07 -06:00
Adding a TypeORM smoke test
This commit is contained in:
@@ -23,8 +23,12 @@ teardown() {
|
||||
rm -f /tmp/mysql.sock
|
||||
}
|
||||
|
||||
@test "Peewee ORM smoke test" {
|
||||
skip "Not implemented yet"
|
||||
}
|
||||
|
||||
# Peewee is a lightweight ORM library for Python applications
|
||||
@test "peewee ORM test suite" {
|
||||
@test "Peewee ORM test suite" {
|
||||
skip "Dolt does not pass all tests yet"
|
||||
|
||||
# peewee tests require the test database to be named peewee_test
|
||||
@@ -40,15 +44,15 @@ teardown() {
|
||||
|
||||
# Prisma is an ORM for Node/TypeScript applications. This is a simple smoke test to make sure
|
||||
# Dolt can support the most basic Prisma operation.
|
||||
@test "prisma ORM smoke test" {
|
||||
mysql --protocol TCP -u dolt -e "create database obsidian;"
|
||||
@test "Prisma ORM smoke test" {
|
||||
mysql --protocol TCP -u dolt -e "create database dolt;"
|
||||
|
||||
cd prisma
|
||||
npm install
|
||||
npx -c "prisma migrate dev --name init"
|
||||
}
|
||||
|
||||
@test "prisma ORM test suite" {
|
||||
@test "Prisma ORM test suite" {
|
||||
skip "Not implemented yet"
|
||||
|
||||
# More info on running Prisma's tests here:
|
||||
@@ -58,6 +62,14 @@ teardown() {
|
||||
# https://github.com/prisma/prisma/tree/main/packages/integration-tests/src/__tests__/integration/mysql
|
||||
}
|
||||
|
||||
@test "TypeORM smoke test" {
|
||||
mysql --protocol TCP -u dolt -e "create database dolt;"
|
||||
|
||||
cd typeorm
|
||||
npm install
|
||||
npm start
|
||||
}
|
||||
|
||||
# Turn this test on to prevent the container from exiting if you need to exec a shell into
|
||||
# the container to debug failed tests.
|
||||
#@test "Pause container for an hour to debug failures" {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = "mysql://dolt@localhost:3306/obsidian"
|
||||
url = "mysql://dolt@localhost:3306/dolt"
|
||||
}
|
||||
|
||||
model Sample {
|
||||
|
||||
13
integration-tests/orm-tests/typeorm/README.md
Normal file
13
integration-tests/orm-tests/typeorm/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# TypeORM Smoke Test
|
||||
|
||||
This project was created with: `typeorm init --name typeorm-smoketest --database mysql`
|
||||
|
||||
Database settings are inside `data-source.ts` file and is configured to hit a Dolt sql-server on the default port, for the dolt root, with no password, for the database named "dolt".
|
||||
|
||||
The `index.ts` file is the main entry point and will insert a new record into the database, then load it, print
|
||||
success, and exit with a zero exit code. If any errors are encountered, they are logged, and the process exits with a
|
||||
non-zero exit code.
|
||||
|
||||
To run this smoke test project:
|
||||
1. Run `npm install` command
|
||||
2. Run `npm start` command
|
||||
20
integration-tests/orm-tests/typeorm/package.json
Normal file
20
integration-tests/orm-tests/typeorm/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "typeorm-smoketest",
|
||||
"version": "0.0.1",
|
||||
"description": "DoltDB smoke test for TypeORM integration",
|
||||
"type": "commonjs",
|
||||
"devDependencies": {
|
||||
"ts-node": "^10.7.0",
|
||||
"@types/node": "^16.11.10",
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"typeorm": "^0.3.10",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"mysql": "^2.14.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "ts-node src/index.ts",
|
||||
"typeorm": "typeorm-ts-node-commonjs"
|
||||
}
|
||||
}
|
||||
17
integration-tests/orm-tests/typeorm/src/data-source.ts
Normal file
17
integration-tests/orm-tests/typeorm/src/data-source.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import "reflect-metadata"
|
||||
import { DataSource } from "typeorm"
|
||||
import { User } from "./entity/User"
|
||||
|
||||
export const AppDataSource = new DataSource({
|
||||
type: "mysql",
|
||||
host: "localhost",
|
||||
port: 3306,
|
||||
username: "dolt",
|
||||
password: "",
|
||||
database: "dolt",
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [User],
|
||||
migrations: [],
|
||||
subscribers: [],
|
||||
})
|
||||
18
integration-tests/orm-tests/typeorm/src/entity/User.ts
Normal file
18
integration-tests/orm-tests/typeorm/src/entity/User.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
@Column()
|
||||
firstName: string
|
||||
|
||||
@Column()
|
||||
lastName: string
|
||||
|
||||
@Column()
|
||||
age: number
|
||||
|
||||
}
|
||||
23
integration-tests/orm-tests/typeorm/src/index.ts
Normal file
23
integration-tests/orm-tests/typeorm/src/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { AppDataSource } from "./data-source"
|
||||
import { User } from "./entity/User"
|
||||
|
||||
AppDataSource.initialize().then(async () => {
|
||||
console.log("Inserting a new user into the database...")
|
||||
const user = new User()
|
||||
user.firstName = "Timber"
|
||||
user.lastName = "Saw"
|
||||
user.age = 25
|
||||
await AppDataSource.manager.save(user)
|
||||
console.log("Saved a new user with id: " + user.id)
|
||||
|
||||
console.log("Loading users from the database...")
|
||||
const users = await AppDataSource.manager.find(User)
|
||||
console.log("Loaded users: ", users)
|
||||
|
||||
console.log("Smoke test passed!")
|
||||
process.exit(0)
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
console.log("Smoke test failed!")
|
||||
process.exit(1)
|
||||
})
|
||||
15
integration-tests/orm-tests/typeorm/tsconfig.json
Normal file
15
integration-tests/orm-tests/typeorm/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es5",
|
||||
"es6"
|
||||
],
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./build",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user