Skip to content

feat(firestore): initial support#245

Merged
brianquinlan merged 31 commits intogoogleapis:mainfrom
brianquinlan:firestore
Apr 24, 2026
Merged

feat(firestore): initial support#245
brianquinlan merged 31 commits intogoogleapis:mainfrom
brianquinlan:firestore

Conversation

@brianquinlan
Copy link
Copy Markdown
Contributor

@brianquinlan brianquinlan commented Apr 20, 2026

Adds the configuration, tests, and example for a new generated package: package:google_cloud_firestore_v1

Adds terraform configuration for firestore for integration tests.

Before this change, only package:google_cloud_storage had tests that used the firebase emulator suite. The new firestore package adds additional emulator tests so:

  1. the emulator configuration is moved from google_cloud_storage/emulator_test to a top-level firestore_emulators directory.
  2. the emulator workflow is moved from .github/workflows/gcs_emulator_tests.yaml to dart_checks.yaml and is run against all tests (with the "firebase_emulator" tag) instead of just cloud storage tests.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the google_firestore_v1 package, including Terraform configurations for Firestore resources, Firebase emulator setup, and initial library generation with tests and examples. Several issues were identified regarding incorrect package naming in imports within the example and test files, which would lead to compilation errors. Additionally, the librarian.yaml configuration contains a filename mismatch in the 'keep' list that would cause the newly added test file to be deleted during regeneration, and a comment in the example code incorrectly references the Generative Language API instead of Firestore.

Comment thread generated/google_cloud_firestore_v1/example/main.dart
Comment thread generated/google_cloud_firestore_v1/test/firestore_test.dart
Comment thread librarian.yaml Outdated
Comment thread generated/google_cloud_firestore_v1/example/main.dart Outdated
@brianquinlan
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Google Cloud Firestore v1 library, including Terraform configurations for provisioning Firestore resources, Firebase emulator setup for local development, and the generated Dart client with accompanying tests and examples. The review feedback suggests improving the Terraform configuration by using variables for location instead of hardcoded values. Additionally, for the test suite, it is recommended to use environment variables for the emulator endpoint, remove an unnecessary async keyword from the test registration function, and include the required import for environment access.

resource "google_firestore_database" "default" {
project = var.project
name = "(default)"
location_id = "us-central1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The location_id is hardcoded to us-central1. Since a region variable is already defined and used for other resources in this file, it should be used here as well to ensure consistency and allow for easier multi-region deployments.

  location_id = var.region


@TestOn('vm')
library;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add import 'dart:io'; to allow accessing environment variables via Platform.environment.

import 'dart:io';


const databaseId = '(default)';

void firestoreTest(Future<Firestore> Function() createFirestore) async {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The firestoreTest function is used to register tests and setup/teardown blocks. It should not be marked as async because it does not perform any asynchronous operations itself. In Dart's package:test, registering tests inside an async function is generally discouraged as it can lead to race conditions or tests not being discovered if an await is introduced before the test registration calls.

void firestoreTest(Future<Firestore> Function() createFirestore) {

firestoreTest(
() async => Firestore(
client: http.Client(),
endPoint: Uri.http('127.0.0.1:8080'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The emulator endpoint is hardcoded to 127.0.0.1:8080. It should instead respect the FIRESTORE_EMULATOR_HOST environment variable if it is set, matching the instructions provided in the README.md and allowing for more flexible test environments.

          endPoint: Uri.http(Platform.environment['FIRESTORE_EMULATOR_HOST'] ?? '127.0.0.1:8080'),

@brianquinlan brianquinlan merged commit 42a6536 into googleapis:main Apr 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants