Skip to content

[FEAT] Add integration tests against Firestore emulator for GCP templates #54

@colbytimm

Description

@colbytimm

Summary

Add integration tests for Python and TypeScript GCP templates that run against the Firestore emulator in CI. The Firestore emulator is lightweight and runs via gcloud emulators firestore start or a Docker image. Tests exercise the repository layer against a real Firestore API to validate CRUD operations.

Category: testing, gcp

Acceptance Criteria

  • GHA workflow for Python and TypeScript adds a test-integration-gcp job
  • Firestore emulator runs in CI (via google/cloud-sdk Docker image or direct install + gcloud emulators firestore start)
  • FIRESTORE_EMULATOR_HOST environment variable set to point tests at the emulator
  • Integration tests for each template exercise all 5 CRUD operations through the repository layer:
    • Create a document
    • Get a document by ID
    • List all documents
    • Update a document (PATCH)
    • Soft-delete a document (set isDeleted: true)
  • Tests verify correct Firestore document structure (including isDeleted, createdTimestamp, updatedTimestamp)
  • Makefile adds a test-integration target (or extends existing one)
  • Tests are GCP-variant only (skipped for Azure matrix entries)

Implementation Notes

Firestore Emulator in GHA

Option A: Direct install

- name: Start Firestore Emulator
  run: |
    gcloud components install cloud-firestore-emulator --quiet
    gcloud emulators firestore start --host-port=localhost:8080 &
    sleep 5
  env:
    FIRESTORE_EMULATOR_HOST: localhost:8080

Option B: Docker service

services:
  firestore:
    image: google/cloud-sdk:latest
    ports:
      - 8080:8080
    command: gcloud emulators firestore start --host-port=0.0.0.0:8080

Key Behavior

  • When FIRESTORE_EMULATOR_HOST is set, the Firestore SDK automatically connects to the emulator instead of production
  • No authentication or project ID required for emulator
  • Data is ephemeral (cleared when emulator stops)

Scope

  • Python (google-cloud-firestore) and TypeScript (@google-cloud/firestore) only
  • .NET and Go GCP support is a separate story

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions