Skip to content

Commit 1e98220

Browse files
NovaMageclaude
andcommitted
test: share NixOS-aware Postgres bootstrap between both EmbeddedPostgres instances
Test 9 was started with a bare EmbeddedPostgres.start(), bypassing the NOMAD_PG_TARBALL resolver applied to the first instance. On NixOS, the fallback to zonky's bundled generic-Linux binaries failed with the dynamic-linker error from stub-ld. Extract the bootstrap into startEmbeddedPostgres() and route both instances through it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 217eb27 commit 1e98220

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • sbt-plugin/src/sbt-test/nomad/clean-and-migrate-postgres/src/main/scala

sbt-plugin/src/sbt-test/nomad/clean-and-migrate-postgres/src/main/scala/Main.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import nomad.{Migrator, SQLMigration, SupportedDatabase}
22
import io.zonky.test.db.postgres.embedded.EmbeddedPostgres
33

44
object Main {
5-
def main(args: Array[String]): Unit = {
6-
// On NixOS zonky's bundled generic-Linux binaries fail to load. NOMAD_PG_TARBALL
7-
// (set by the flake devshell) overrides the binary source with a tarball of the
8-
// system postgres.
9-
val pg = sys.env.get("NOMAD_PG_TARBALL").filter(_.nonEmpty) match {
5+
// On NixOS zonky's bundled generic-Linux binaries fail to load. NOMAD_PG_TARBALL
6+
// (set by the flake devshell) overrides the binary source with a tarball of the
7+
// system postgres.
8+
private def startEmbeddedPostgres(): EmbeddedPostgres =
9+
sys.env.get("NOMAD_PG_TARBALL").filter(_.nonEmpty) match {
1010
case Some(path) =>
1111
// nix-store postgres defaults unix_socket_directories to /run/postgresql,
1212
// which doesn't exist in this sandbox — point it at the JVM temp dir instead.
@@ -18,6 +18,9 @@ object Main {
1818
case None => EmbeddedPostgres.start()
1919
}
2020

21+
def main(args: Array[String]): Unit = {
22+
val pg = startEmbeddedPostgres()
23+
2124
try {
2225
val ds = pg.getPostgresDatabase()
2326
val migrations = Vector(SQLMigration("migrations/M001_CreateUsers.sql"))
@@ -218,7 +221,7 @@ object Main {
218221
// additionally verifies that the fix is idempotent: a second cleanAndMigrate() call
219222
// after self-heal must also converge (the bug was described as self-perpetuating).
220223
// Use a fresh embedded PG so earlier tests do not interfere with the public schema.
221-
val pg2 = EmbeddedPostgres.start()
224+
val pg2 = startEmbeddedPostgres()
222225
try {
223226
val ds2 = pg2.getPostgresDatabase()
224227

0 commit comments

Comments
 (0)