emulator

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package emulator provides helpers for working with firebase emulators, e.g. to populate them with data or reset them. This is useful mostly for development and testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmailAlreadyExistsError

func IsEmailAlreadyExistsError(err error) bool

Returns true if the given error returned by the CreateUser method was due to an account with the email address already existing.

Types

type AuthEmulatorClient

type AuthEmulatorClient struct {
	// contains filtered or unexported fields
}

AuthEmulatorClient can be used to initialize and reset the firebase auth emulator for tests. It provides functions to create users accounts, sign a user in and obtain a JWT token, and reset the emulator by deleting all accounts.

func NewAuthEmulatorClient

func NewAuthEmulatorClient() (*AuthEmulatorClient, error)

Creates a new AuthEmulatorClient. The FIREBASE_PROJECT_ID and FIREBASE_AUTH_EMULATOR_HOST environment variables must be set for this to work.

func (*AuthEmulatorClient) CreateUser

func (a *AuthEmulatorClient) CreateUser(email, password string, emailVerified bool) (string, error)

Create a new user in the emulator and return the user id.

func (*AuthEmulatorClient) ResetEmulator

func (a *AuthEmulatorClient) ResetEmulator() error

Reset emulator by deleting all user accounts.

func (*AuthEmulatorClient) SignInUser

func (a *AuthEmulatorClient) SignInUser(email, password string) (string, error)

Obtain a JWT token from the emulator using the provided email and password.

type FirestoreEmulatorClient

type FirestoreEmulatorClient struct {
	// contains filtered or unexported fields
}

FirestoreEmulatorClient can be used to reset the firestore emulator by deleting all data. When testing, we usually want to reset the emulator after every test, so that data created by one test cannot influence another.

func NewFirestoreEmulatorClient

func NewFirestoreEmulatorClient() (*FirestoreEmulatorClient, error)

Creates a new FirestoreEmulatorClient. The FIREBASE_PROJECT_ID and FIRESTORE_EMULATOR_HOST environment variables must be set for this to work.

func (*FirestoreEmulatorClient) ResetEmulator

func (e *FirestoreEmulatorClient) ResetEmulator() error

Reset the firestore emulator by deleting all collection and documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL