我想运行一个只在内存中运行的小型PostgreSQL数据库,用于我编写的每个单元测试.例如:
@Before
void setUp() {
String port = runPostgresOnRandomPort();
connectTo("postgres://localhost:"+port+"/in_memory_db");
// ...
}
Run Code Online (Sandbox Code Playgroud)
理想情况下,我将在版本控件中检查一个postgres可执行文件,单元测试将使用该版本控件.
有点像HSQL
,但对于postgres.我怎样才能做到这一点?
我可以获得这样的Postgres版本吗?如何指示不使用磁盘?