mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-25 17:30:56 +08:00
- Introduced uniform skipping functions in the db package: SkipPGUnavailable and SkipNoPG. - Updated all relevant test files to utilize these new functions for better consistency and readability. - Added new db/testpg.go file to house the skipping logic. - Created architecture and operations documentation to provide a comprehensive overview of the ARTEX system. - Added a verification script to streamline local testing and ensure code quality.
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package db
|
|
|
|
// skipper is the part of testing.TB used by the PostgreSQL test helpers below.
|
|
// A local interface keeps the production package from importing "testing":
|
|
// *testing.T, *testing.B and the test-only wrappers all satisfy it.
|
|
type skipper interface {
|
|
Helper()
|
|
Skipf(format string, args ...any)
|
|
}
|
|
|
|
// SkipPGUnavailable skips the calling test with one uniform reason when err
|
|
// reports that the test database could not be configured or opened.
|
|
//
|
|
// Every PostgreSQL-dependent test uses this instead of spelling the skip text
|
|
// inline (the old variants differed by package: "no database config",
|
|
// "database unavailable", "postgres unavailable — skipping", ...). Call it
|
|
// with the err returned by DSN(), Open() or NewManager(). It does not change
|
|
// when a test skips — only how the reason is reported.
|
|
func SkipPGUnavailable(t skipper, err error) {
|
|
t.Helper()
|
|
if err != nil {
|
|
t.Skipf("postgres unavailable (%v)", err)
|
|
}
|
|
}
|
|
|
|
// SkipNoPG skips with the same uniform reason when a store is unexpectedly nil
|
|
// after a successful open (for example Manager.pg when only some backends are
|
|
// configured). It carries no error because there is none to report.
|
|
func SkipNoPG(t skipper) {
|
|
t.Helper()
|
|
t.Skip("postgres unavailable")
|
|
}
|