@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 38 lines 1.04 KB
Raw
1 import { MySqlContainer } from "@testcontainers/mysql"
2 import { PostgreSqlContainer } from "@testcontainers/postgresql"
3 import type { TestProject } from "vitest/node"
4
5 export interface ClusterDatabases {
6 readonly mysql: string
7 readonly pg: string
8 }
9
10 declare module "vitest" {
11 export interface ProvidedContext {
12 readonly clusterDatabases: ClusterDatabases
13 }
14 }
15
16 const makeMysqlContainer = () =>
17 new MySqlContainer("mysql:lts").withHealthCheck({
18 test: [
19 "CMD-SHELL",
20 "MYSQL_PWD=\"$MYSQL_ROOT_PASSWORD\" mysqladmin ping --protocol TCP --host 127.0.0.1 --user root --silent"
21 ],
22 interval: 250,
23 timeout: 1000,
24 retries: 1000
25 })
26
27 export default function setup(project: TestProject) {
28 return Promise.all([
29 new PostgreSqlContainer("postgres:alpine").start(),
30 makeMysqlContainer().start()
31 ]).then(([pg, mysql]) => {
32 project.provide("clusterDatabases", {
33 mysql: mysql.getConnectionUri(),
34 pg: pg.getConnectionUri()
35 })
36 return () => Promise.all([pg.stop(), mysql.stop()]).then(() => undefined)
37 })
38 }