dstest

package module
v0.0.0-...-1e6bbee Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package dstest contains functionality to help with testing code that relies on the Google Cloud Datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emulator

func Emulator(ctx context.Context, t testing.TB, opts ...Option) *datastore.Client

Emulator starts a Cloud Datastore emulator; see https://cloud.google.com/datastore/docs/tools/datastore-emulator. When the test ends, the returned client is automatically closed and the emulator process is killed. If the given context has a deadline, it is applied to the entire running time of the emulator process; this means that you shouldn’t pass t.Context() because it’ll get cancelled before Emulator gets a chance to clean up the datastore process. Unless overridden by passing Option arguments, this function will start the emulator in Firestore mode and wait up to 20 seconds for it to start up and stop, respectively.

Types

type Mode

type Mode int

Mode is an Option that determines the mode of the datastore emulator; either Firestore or legacy mode.

const (
	FirestoreMode Mode = iota
	LegacyMode
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an option for Emulator. The current implementations are Mode, StartTimeout, and StopTimeout.

type StartTimeout

type StartTimeout time.Duration

StartTimeout is an Option that determines how long to wait for the datastore emulator to start.

type StopTimeout

type StopTimeout time.Duration

StopTimeout is an Option that determines how long to wait for the datastore emulator to stop.

Jump to

Keyboard shortcuts

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