Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/models/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func loadSQLData(db *sqlx.DB, ctx context.Context, filename string) error {

// LoadTestSQLData loads all the required test SQL files.
func LoadTestSQLData(db *sqlx.DB, ctx context.Context) error {
// In-memory SQLite gives each pooled connection its OWN empty database. The component
// helper resolves versions concurrently (worker pool), so multiple connections would race
// and some queries would hit a connection without the loaded fixtures ("no such table").
// Pin the pool to a single connection so every query sees the same in-memory database.
db.SetMaxOpenConns(1)
files := []string{"../models/tests/mines.sql", "../models/tests/all_urls.sql", "../models/tests/versions.sql",
"../models/tests/licenses.sql",
"../models/tests/component_crypto.sql", "../models/tests/component_crypto_libraries.sql",
Expand Down
Loading