Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

LeoColman/Embedded-Firestore

Repository files navigation

Embedded-Firestore

GitHub Workflow Status GitHub Maven Central

Embedded Cloud Firestore client, to be used in unit testing Firestore.

This library simulates the features from Firestore, allowing you to write Unit Tests without mocking every single function from Firestore.

This might not be as precise as the real Firestore, but will come close enough for most usages.

Setting up with Gradle

Add this line to your build.gradle dependencies, and you should be good to go!

testImplementation("top.colman.embeddedfirestore:embedded-firestore:${version}")

Usage

Embedded Firestore usage is pretty simple.

val client: Firestore = EmbeddedFirestore().createClient {
    // Optional: Start a collection
    createCollection("MyCollectionId") {
    
        // Optional: Start some documents
        createDocument("MyDocumentId", myPojo)
        createDocument("MyOtherDocumentId", myDocumentMap)
    }
}

val myTarget = MyClassThatUsesFirestore(client)

Project State

This library is in a very early state. I just hacked around until my use case was met, and tried to make it at least usable for simpler cases.

Contributing

If you believe that you can help me improve the features of this library, please feel free to make a pull request or open an issue!