Files
summercms/modules/lagoon/export_docs_test.go
Jakub Zych c517db564c docs(flare,kiosk,lagoon): compile README Go examples via src= (quick-261118-qsd)
- flare: send region run by TestDocsNotifyReply against a loopback TLS push
  service; blogSubscriptions and the publish-source region run by
  TestDocsSubscriptionSource on a Postgres container (skips under -short)
- kiosk: write, newest and client regions run by TestDocsWriteManifest (a
  copy of the literal fixture), ExampleVersionsResponse and
  TestDocsBlogReleases (httptest registry); the CheckT fence reuses
  TestPluginManifest
- lagoon: new open region run by TestDocsOpenFromApp (DocsDSN added to
  export_docs_test.go); the model, create-post, on-database, publish and
  migrations fences reuse the Database pages' targets
2026-11-18 19:53:27 +01:00

31 lines
802 B
Go

package lagoon
import (
"testing"
"gorm.io/gorm"
)
// DocsDB returns a GORM handle on a fresh database named name in this
// package's Postgres harness, for the database-backed docs examples in
// example_test.go. It skips under -short and fails when the harness has no
// database, like the package's other database tests.
func DocsDB(t *testing.T, name string) *gorm.DB {
t.Helper()
db, _ := dedicatedDB(t, name)
gdb, err := Use(t.Context(), db)
if err != nil {
t.Fatal(err)
}
return gdb
}
// DocsDSN returns the DSN of a fresh database named name in this package's
// Postgres harness, for the docs example that opens the pool from config.
// It skips under -short like DocsDB.
func DocsDSN(t *testing.T, name string) string {
t.Helper()
_, dsn := dedicatedDB(t, name)
return dsn
}