Skip to content

store-postgres tests: start an embedded Postgres when POSTGRES_TEST_URL is unset #4

Closed

Description

@jherr

Problem

packages/store-postgres integration tests need a running Postgres. tests/helpers.ts reads POSTGRES_TEST_URL at module load and throws Set POSTGRES_TEST_URL to run Postgres integration tests. from createStorage() when it is unset (most suites are also describe.skipIf(!url)). So pnpm test:pr / pnpm test:ci fail or skip on any machine without Postgres, including the Studio that runs the assembly line. CI gets one from a postgres:16 service container; local machines don't.

Acceptance criteria

  1. With POSTGRES_TEST_URL unset, pnpm --filter @tanstack/cms-store-postgres test:lib starts an embedded Postgres, runs the full suite against it (no suites skipped by skipIf(!url), no "Set POSTGRES_TEST_URL" error), and shuts it down afterwards (no leftover postgres process or temp data directory after the run).
  2. With POSTGRES_TEST_URL set, the tests use that URL exactly as today and no embedded server starts.
  3. The embedded server needs no system install (no Homebrew Postgres, no Docker); a fresh pnpm install is enough.
  4. The embedded-server package is a devDependency of @tanstack/cms-store-postgres only; the package's dependencies and peerDependencies are unchanged.
  5. pnpm --filter @tanstack/cms-store-postgres test:coverage still meets the existing coverage thresholds when run against the embedded server.

Out of scope

  • Changing pr.yml, anything under .github/**, or the CI Postgres service.
  • Changing anything under packages/store-postgres/src.
  • Changing other packages' test setups or root CI scripts.
  • Changing the Postgres-backed test assertions themselves (only how the server/URL is provided).

Original report

Problem

packages/store-postgres integration tests need a running Postgres. tests/helpers.ts throws Set POSTGRES_TEST_URL to run Postgres integration tests. when the variable is unset, so pnpm test:pr and pnpm test:ci fail on any machine that has no Postgres, including the Studio that runs the assembly line. CI provides one through a postgres:16 service container; local machines don't.

Acceptance criteria

  • With POSTGRES_TEST_URL unset, pnpm --filter @tanstack/cms-store-postgres test:lib starts an embedded Postgres, runs the full suite against it, and shuts it down afterwards
  • With POSTGRES_TEST_URL set, the tests use that URL exactly as today, and no embedded server starts
  • The embedded server needs no system install (no Homebrew Postgres, no Docker)
  • The embedded server dependency is a devDependency only; the published package's runtime dependencies don't change

Out of scope

  • Changing pr.yml or the CI Postgres service
  • Changing anything under packages/store-postgres/src

Activity

  1. added
    state:needs-triage
    on Oct 30, 2026
  2. added
    agent:blocked
    on Oct 30, 2026
  3. cms-triager commented on Oct 30, 2026

    @cms-triager

    triager stopped: the run did not end with one valid handoff comment (claude exit 1). Fix the cause, remove agent:blocked, and re-add the state label to retry.

  4. added
    state:needs-triage
    and removed
    agent:blocked
    state:needs-triage
    on Oct 30, 2026
  5. added
    risk:two-way
    state:ready
    and removed
    state:needs-triage
    on Oct 30, 2026
  6. cms-triager commented on Oct 30, 2026

    @cms-triager
    handoff:
      from: triager
      to: looper
      issue: 4
      pr: null
      attempt: 1
      risk: two-way
      risk_reasons: [test-infra-only, dev-dependency]
      summary: Start an embedded Postgres for store-postgres tests when POSTGRES_TEST_URL is unset
      acceptance:
        - With POSTGRES_TEST_URL unset, `pnpm --filter @tanstack/cms-store-postgres test:lib` starts an embedded Postgres, runs the full suite against it (no suites skipped by skipIf(!url), no "Set POSTGRES_TEST_URL" error), and shuts it down afterwards (no leftover postgres process or temp data directory)
        - With POSTGRES_TEST_URL set, the tests use that URL exactly as today and no embedded server starts
        - The embedded server needs no system install (no Homebrew Postgres, no Docker); a fresh `pnpm install` is enough
        - The embedded-server package is a devDependency of @tanstack/cms-store-postgres only; its dependencies and peerDependencies are unchanged
        - "`pnpm --filter @tanstack/cms-store-postgres test:coverage` still meets the existing coverage thresholds against the embedded server"
      out_of_scope:
        - Changing pr.yml, anything under .github/**, or the CI Postgres service
        - Changing anything under packages/store-postgres/src
        - Changing other packages' test setups or root CI scripts
        - Changing the Postgres-backed test assertions themselves
      notes_for_next: >
        Files: packages/store-postgres/package.json, vitest.config.ts, tests/helpers.ts, a new
        tests/global-setup.ts, and pnpm-lock.yaml. helpers.ts reads POSTGRES_TEST_URL at module load
        and suites use describe.skipIf(!url), so the URL must exist before test files import helpers.
        Suggested approach: a vitest globalSetup that, if POSTGRES_TEST_URL is unset, starts an
        embedded server (e.g. the `embedded-postgres` npm package, which ships platform binaries as
        optional deps) on a free port with a temp data dir, sets POSTGRES_TEST_URL (or uses
        provide/inject), and returns a teardown that stops it and removes the dir. Check whether pnpm
        needs the package allowed in onlyBuiltDependencies. The nx test:lib/test:coverage inputs
        already key on POSTGRES_TEST_URL; leave them. No changeset needed (devDependency + tests only).
        Test: `pnpm --filter @tanstack/cms-store-postgres test:lib` with the variable unset and set,
        then `pnpm test:pr`.

    Two-way: only tests, vitest config and a devDependency in packages/store-postgres. Test files there are two-way, src/** is untouched, and runtime behaviour doesn't change. The issue was filed by a maintainer and labelled state:needs-triage. The earlier bot comment came from a failed triager run, not from a problem with the issue.

  7. added
    state:ready
    and removed
    state:ready
    on Oct 30, 2026
  8. added
    state:in-progress
    and removed
    state:ready
    on Oct 30, 2026
  9. added
    agent:blocked
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:blockedrisk:two-waystate:in-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions