Documentation
¶
Index ¶
- func CreateMigrateDatabase(t testing.TB, dbFile string)
- func MigrateMySQLDatabase(t *testing.T, dbURL string)
- func MigrateNarInfoToDatabase(ctx context.Context, db database.Querier, hash string, ni *narinfo.NarInfo) error
- func MigratePostgresDatabase(t *testing.T, dbURL string)
- func MustParseURL(t *testing.T, us string) *url.URL
- func MustRandBase16NarHash() string
- func MustRandBase32NarHash() string
- func MustRandNarInfoHash() string
- func MustRandString(n int) string
- func RandBase16NarHash() (string, error)
- func RandBase32NarHash() (string, error)
- func RandNarInfoHash() (string, error)
- func RandString(n int) (string, error)
- func RegisterNarInfoAsUnmigrated(ctx context.Context, db database.Querier, hash string, ni *narinfo.NarInfo) error
- func S3TestConfig(t *testing.T) *s3.Config
- func SetupMySQL(t *testing.T) (database.Querier, string, func())
- func SetupPostgres(t *testing.T) (database.Querier, string, func())
- func SetupSQLite(t *testing.T) (database.Querier, func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMigrateDatabase ¶
CreateMigrateDatabase will create all necessary directories, and will create the sqlite3 database (if necessary) and migrate it.
func MigrateMySQLDatabase ¶ added in v0.6.0
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
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
MustParseURL parses the url (string) and returns or fails the test.
func MustRandBase16NarHash ¶ added in v0.9.0
func MustRandBase16NarHash() string
func MustRandBase32NarHash ¶ added in v0.9.0
func MustRandBase32NarHash() string
func MustRandNarInfoHash ¶ added in v0.8.5
func MustRandNarInfoHash() string
func MustRandString ¶ added in v0.8.5
MustRandString returns the string returned by RandString. If RandString returns an error, it will panic.
func RandBase16NarHash ¶ added in v0.9.0
func RandBase32NarHash ¶ added in v0.9.0
func RandNarInfoHash ¶ added in v0.8.5
func RandString ¶ added in v0.8.5
RandString returns a random string of length n using crypto/rand.Reader as the random reader.
func RegisterNarInfoAsUnmigrated ¶ added in v0.9.0
func RegisterNarInfoAsUnmigrated(ctx context.Context, db database.Querier, hash string, ni *narinfo.NarInfo) error
RegisterNarInfoAsUnmigrated registers a narinfo in the database as unmigrated (no URL).
func S3TestConfig ¶ added in v0.9.0
S3TestConfig returns the S3 configuration for testing. It skips the test if any required environment variable is missing.
func SetupMySQL ¶ added in v0.7.2
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
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
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.