Files
wehub-resource-sync 75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:11:07 +08:00

31 lines
1.2 KiB
Go

// Package logicaltesting holds the engine-agnostic helpers shared by the
// per-engine logical backup/restore test packages (mysql, mariadb, mongodb,
// postgresql). It is normal (non-_test) code so the sibling test packages can
// import it; nothing in production imports anything under tests/, so it never
// enters the shipped binary.
package logicaltesting
import (
"testing"
"databasus-backend/internal/features/restores/restoring"
cache_utils "databasus-backend/internal/util/cache"
)
// Setup clears this worker's Valkey logical DB and installs the in-process
// restorer the per-engine tests drive through the API. It returns a teardown
// to run from each engine package's TestMain so every parallel test binary
// runs against its own isolated control plane.
func Setup() func() {
// Best-effort clean slate for this worker's Valkey logical DB; a stale key
// here is harmless because each worker uses its own DB and namespace.
_ = cache_utils.ClearAllCache()
restorer := restoring.CreateTestRestorer()
cancelRestore := restoring.StartRestorerForTest(&testing.T{}, restorer)
return func() {
restoring.StopRestorerForTest(&testing.T{}, cancelRestore, restorer)
}
}