(driver?: string)
| 308 | }); |
| 309 | |
| 310 | export function tests(driver?: string) { |
| 311 | describe('common', () => { |
| 312 | // afterAll(async () => { |
| 313 | // await mysqlContainer?.stop().catch(console.error); |
| 314 | // }); |
| 315 | |
| 316 | beforeEach(async (ctx) => { |
| 317 | const { db } = ctx.mysql; |
| 318 | await db.execute(sql`drop table if exists userstest`); |
| 319 | await db.execute(sql`drop table if exists users2`); |
| 320 | await db.execute(sql`drop table if exists cities`); |
| 321 | await db.execute(sql`drop table if exists \`all_types\``); |
| 322 | |
| 323 | if (driver !== 'planetscale') { |
| 324 | await db.execute(sql`drop schema if exists \`mySchema\``); |
| 325 | await db.execute(sql`create schema if not exists \`mySchema\``); |
| 326 | } |
| 327 | |
| 328 | await db.execute( |
| 329 | sql` |
| 330 | create table userstest ( |
| 331 | id serial primary key, |
| 332 | name text not null, |
| 333 | verified boolean not null default false, |
| 334 | jsonb json, |
| 335 | created_at timestamp not null default now() |
| 336 | ) |
| 337 | `, |
| 338 | ); |
| 339 | |
| 340 | await db.execute( |
| 341 | sql` |
| 342 | create table users2 ( |
| 343 | id serial primary key, |
| 344 | name text not null, |
| 345 | city_id int references cities(id) |
| 346 | ) |
| 347 | `, |
| 348 | ); |
| 349 | |
| 350 | await db.execute( |
| 351 | sql` |
| 352 | create table cities ( |
| 353 | id serial primary key, |
| 354 | name text not null |
| 355 | ) |
| 356 | `, |
| 357 | ); |
| 358 | |
| 359 | if (driver !== 'planetscale') { |
| 360 | // mySchema |
| 361 | await db.execute( |
| 362 | sql` |
| 363 | create table \`mySchema\`.\`userstest\` ( |
| 364 | \`id\` serial primary key, |
| 365 | \`name\` text not null, |
| 366 | \`verified\` boolean not null default false, |
| 367 | \`jsonb\` json, |
no test coverage detected