Documentation
¶
Overview ¶
Package testdb creates the database that one database case uses alone (the case database).
The database that ORM_TEST_MYSQL_DSN and ORM_TEST_POSTGRES_DSN point to is shared by several runs and sessions, so it cannot be assumed empty. Installing a schema or checking for an empty database A case creates its own database with New, and the database is deleted when the case ends (even after a failure). The shared DSN is used only as an admin connection and creates nothing in its database.
PostgreSQL also creates a database, not a schema. Empty() counts the non-public schemas by their content, so an empty database cannot be checked with a case schema inside a shared database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseOf ¶
DatabaseOf is the database name of a MySQL or PostgreSQL DSN.
func DirNames ¶ added in v0.0.19
DirNames returns the entry names of dir in the order of os.ReadDir; a failure fails the test.
func Name ¶
func Name() string
Name returns the next case database name, orm_case_<pid>_<number>. For a case that cannot create a database, such as a case bound to one PgBouncer database, it is used as its table name.
func New ¶
New creates a case database for the driver ("sqlite", "mysql", "postgres") and returns its DSN. For MySQL and PostgreSQL it creates the database orm_case_<pid>_<number> on the server of ORM_TEST_<DRIVER>_DSN and changes only the path of the DSN to that name (the query stays as it is). SQLite uses the new file orm-case-<pid>-<number>.sqlite in the OS temp directory. Creating and deleting it is reported as a STEP line of the case (testcase.Of) wrapping t, and deletion runs in t.Cleanup, so it runs even after the case fails. If deletion fails, the case fails with the database name.
Types ¶
This section is empty.