testhelper

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMigrateDatabase

func CreateMigrateDatabase(t testing.TB, dbFile string)

CreateMigrateDatabase will create all necessary directories, and will create the sqlite3 database (if necessary) and migrate it.

func MigrateMySQLDatabase added in v0.6.0

func MigrateMySQLDatabase(t *testing.T, dbURL string)

MigrateMySQLDatabase will migrate the MySQL database using dbmate. The database URL should be in the format: mysql://user:password@host:port/database

func MigrateNarInfoToDatabase added in v0.8.0

func MigrateNarInfoToDatabase(ctx context.Context, db database.Querier, hash string, ni *narinfo.NarInfo) error

MigrateNarInfoToDatabase migrates a single narinfo to the database. This is a test helper that mimics the migration logic in pkg/ncps/migrate_narinfo.go.

func MigratePostgresDatabase added in v0.6.0

func MigratePostgresDatabase(t *testing.T, dbURL string)

MigratePostgresDatabase will migrate the PostgreSQL database using dbmate. The database URL should be in the format: postgresql://user:password@host:port/database

func MustParseURL added in v0.0.14

func MustParseURL(t *testing.T, us string) *url.URL

MustParseURL parses the url (string) and returns or fails the test.

func SetupMySQL added in v0.7.2

func SetupMySQL(t *testing.T) (database.Querier, func())

SetupMySQL sets up a new temporary MySQL database for testing. It requires the NCPS_TEST_ADMIN_MYSQL_URL environment variable to be set. It returns a database connection and a cleanup function.

func SetupPostgres added in v0.7.2

func SetupPostgres(t *testing.T) (database.Querier, func())

SetupPostgres sets up a new temporary PostgreSQL database for testing. It requires the NCPS_TEST_ADMIN_POSTGRES_URL environment variable to be set. It returns a database connection and a cleanup function.

func SetupSQLite added in v0.8.0

func SetupSQLite(t *testing.T) (database.Querier, func())

SetupSQLite sets up a new temporary SQLite database for testing. It returns a database connection and a cleanup function. This function has the same signature as SetupPostgres and SetupMySQL for consistency.

Types

This section is empty.

Jump to

Keyboard shortcuts

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