mongotest

package
v3.49.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package mongotest gives each test its own MongoDB database.

Without GLABS_TEST_MONGO_URI the tests skip, unless GLABS_TEST_MONGO_REQUIRED is set, which turns the skip into a failure. CI sets both, so a database that fails to come up breaks the build instead of quietly skipping every test — without that, "green" and "never ran" are indistinguishable.

There is deliberately no Testcontainers here. The dev container shares its network namespace with a MongoDB and mounts no Docker socket, so a container per test could not start there at all; pointing an environment variable at a database that already exists works in both places, and is faster in CI.

This package exists only for the move to PostgreSQL: it is what lets the store contract suite run against the implementation being replaced. It goes away with the MongoDB store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(t *testing.T) *db.DB

NewDB returns a *db.DB on a fresh database, dropped when the test ends.

func NewDBWithURI

func NewDBWithURI(t *testing.T) (*db.DB, string, string)

NewDBWithURI is NewDB plus the connection string and database name it used.

The import tool takes those two as configuration rather than as a handle -- it is a command, not a library -- so a test that drives it end to end needs them.

It creates the indexes the server creates at startup, because some of them are not decoration: the unique (owner, name) on courses is what makes a second save of the same course a replace rather than a second document.

Types

This section is empty.

Jump to

Keyboard shortcuts

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