integresql 客户端
整合SQL 在集成测试中管理孤立的 PostgreSQL 数据库的客户端
安装 二. 支助 使用量 二. 支助 贡献者 二. 支助 许可证
安装
yarn add --dev @devoxa/integresql-client
要安装IntegreSQL, 请跟随他们 安装指令。 。 。 .
使用量
完整实例
举个例子,你看看 融合测试。 。 。 .
分步指南
- 初始化 IntegreSQL 客户端
import { IntegreSQLClient } from '@devoxa/integresql-client'
const integreSQL = new IntegreSQLClient({ url: 'http://localhost:5000' })
// options.url: The URL of the IntegreSQL instance
- (每一次试跑程序) 获取迁移设置的散列( T)
// The hash can be generated in any way that fits your business logic, the included
// helper creates a SHA1 hash of the file content of all files matching the glob patterns.
const hash = await integreSQL.hashFiles(['./migrations/**/*', './fixtures/**/*'])
- (每一次试跑程序) 初始化模板数据库
await integreSQL.initializeTemplate(hash, async (databaseConfig) => {
await migrateTemplateDatabase(databaseConfig)
await seedTemplateDatabase(databaseConfig)
await disconnectFromDatabase(databaseConfig)
})
- (每次试验之前) 获取一个孤立的测试数据库
const databaseConfig = await integreSQL.getTestDatabase(hash)
帮助者
integreSQL.databaseConfigToConnectionUrl(databaseConfig)- 将数据库配置对象转换为 a 连接 URL
API 请求
您可以直接通过包含的 API 客户端向 IntegreSQL 实例发送请求, 或者可选择
切换新的 IntegreSQLApiClient 你自己来.
await integreSQL.api.reuseTestDatabase(hash, id)
const api = new IntegreSQLApiClient({ url: 'http://localhost:5000' })
await api.reuseTestDatabase(hash, id)
贡献者
感谢这些伟大的人emoji 密钥:
大卫·瑞斯 💻 📖 ⚠️ |
佩德罗·萨拉特谢夫 💻 ⚠️ |
本项目遵循 全部贡献者 规格。 任何捐款都欢迎!
许可证
麻省理工学院