testhelper

package
v0.0.27-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFailed

func AssertFailed(t *testing.T, db *bun.DB, source string)

AssertFailed checks that source's last run is recorded as a failure.

func AssertFailedWithWatermark

func AssertFailedWithWatermark(t *testing.T, db *bun.DB, source string, want time.Time)

AssertFailedWithWatermark checks that source failed and its watermark is still want.

func AssertSucceededAfter

func AssertSucceededAfter(t *testing.T, db *bun.DB, source string, previous time.Time)

AssertSucceededAfter checks that source succeeded and its watermark moved past previous.

func ConfigTime

func ConfigTime(t *testing.T, db *bun.DB, column string) time.Time

ConfigTime reads one timestamp column of the config row.

func ConfigTimeIsNull

func ConfigTimeIsNull(t *testing.T, db *bun.DB, column string) bool

ConfigTimeIsNull reports whether a timestamp column of the config row is unset.

func CreateFriendsOfPHPTable

func CreateFriendsOfPHPTable(t *testing.T, db *bun.DB)

CreateFriendsOfPHPTable creates friends_of_php as the API migrations leave it.

func CreatePackageLinkIndexes

func CreatePackageLinkIndexes(t *testing.T, db *bun.DB)

CreatePackageLinkIndexes adds the unique indexes that package link upserts target.

func CreateTables

func CreateTables(t *testing.T, db *bun.DB, models ...any)

CreateTables creates one table per bun model in the test schema, skipping tables that exist. Sources that share a table, such as package_vulnerability, can each create it.

func DropTable

func DropTable(t *testing.T, db *bun.DB, table string)

DropTable removes a table so that writes to it fail.

func SeedWatermark

func SeedWatermark(t *testing.T, db *bun.DB, source string, watermark time.Time)

SeedWatermark stores a known starting watermark for source.

func SetConfigTime

func SetConfigTime(t *testing.T, db *bun.DB, column string, value time.Time)

SetConfigTime writes one timestamp column of the config row, as another writer would.

func SetupBuildTestDBs

func SetupBuildTestDBs(t *testing.T) (knowledgeDB, configDB *bun.DB)

SetupBuildTestDBs opens knowledge and config schemas like a migrated empty install: null watermarks everywhere. Tests record applied migrations themselves.

func SetupKnowledgeAndConfigTestDB

func SetupKnowledgeAndConfigTestDB(t *testing.T) (*bun.DB, *bun.DB, func())

SetupKnowledgeAndConfigTestDB sets up both knowledge and config database connections for testing

func SetupKnowledgeTestDB

func SetupKnowledgeTestDB(t *testing.T) (*bun.DB, func())

SetupKnowledgeTestDB sets up a knowledge database connection for testing

func SetupSyncTestDB

func SetupSyncTestDB(t *testing.T) *bun.DB

SetupSyncTestDB opens a fresh schema in the throwaway database named by KNOWLEDGE_SYNC_TEST_DSN, holding the source sync and config tables.

func UpstreamTotal

func UpstreamTotal(t *testing.T, db *bun.DB, source string) *int64

UpstreamTotal reads the source's recorded upstream total, nil when none is recorded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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