# Runs crates/db's Postgres-backed integration tests as a build step.
# Not published anywhere - build.yaml's DOCKER_HOST/buildx setup builds this
# ad-hoc and discards the image; only whether the RUN step exits 0 matters.
# TEST_DATABASE_URL is passed as a buildx secret (not a build-arg) so it
# never lands in the image's layer history/cache metadata.
FROM rust:1-bookworm

WORKDIR /workspace
COPY . .

RUN --mount=type=secret,id=test_db_url,required=true \
    export TEST_DATABASE_URL="$(cat /run/secrets/test_db_url)" && \
    cargo test -p db --test ai_credits --test ai_credits_reaper -- --test-threads=1
