name: API - Tests

on:
  push:
    branches: ["**"]

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v4

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: "1.3.6"

      - name: Install dependencies
        run: bun install --frozen-lockfile

      - name: Generate API Prisma client
        run: DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" bunx prisma generate
        working-directory: api

      - name: Run tests
        run: bun test --preload ./tests/setup.ts
        working-directory: api
