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 NewDBWithURI ¶
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.