Documentation
¶
Index ¶
- Constants
- func CreateSchema(t testing.TB, dsn, schemaName string)
- func DropSchema(t testing.TB, dsn, schemaName string)
- func RequireDSN(t testing.TB) string
- func WithSearchPath(dsn, schemaName string) string
- type Project
- func (p *Project) BuildSchema(t testing.TB) *schema.Schema
- func (p *Project) OpenDB(t testing.TB, obs orm.ObservabilityConfig, preflight bool) *dorm.DB
- func (p *Project) OpenSQL(t testing.TB) *sql.DB
- func (p *Project) SaveSnapshot(t testing.TB, s *schema.Schema)
- func (p *Project) WriteFile(t testing.TB, relPath, contents string)
- func (p *Project) WriteJSON(t testing.TB, relPath string, value any)
Constants ¶
View Source
const DefaultModelSource = `package models
import (
"time"
)
type Product struct {
ID string ` + "`orm:\"pk\"`" + `
CompanyID string ` + "`orm:\"company\"`" + `
SKU string ` + "`orm:\"unique\"`" + `
Name string
PriceCents int64
DeletedAt *time.Time ` + "`orm:\"soft_delete\"`" + `
CreatedAt time.Time ` + "`orm:\"created_at\"`" + `
CreatedBy string ` + "`orm:\"created_by\"`" + `
UpdatedAt time.Time ` + "`orm:\"updated_at\"`" + `
UpdatedBy string ` + "`orm:\"updated_by\"`" + `
DeletedBy string ` + "`orm:\"deleted_by\"`" + `
}
type Role struct {
ID string ` + "`orm:\"pk\"`" + `
Code string ` + "`orm:\"unique\"`" + `
Name string
CreatedAt time.Time ` + "`orm:\"created_at\"`" + `
UpdatedAt time.Time ` + "`orm:\"updated_at\"`" + `
}
`
DefaultModelSource is a compact schema fixture used across integration tests.
Variables ¶
This section is empty.
Functions ¶
func CreateSchema ¶
CreateSchema creates a PostgreSQL schema if it does not already exist.
func DropSchema ¶
DropSchema removes a PostgreSQL schema and its contents.
func RequireDSN ¶
RequireDSN returns the PostgreSQL DSN used by the integration tests.
func WithSearchPath ¶
WithSearchPath returns a DSN that targets the given PostgreSQL schema.
Types ¶
type Project ¶
type Project struct {
BaseDSN string
Schema string
Root string
ModelsDir string
MigrationsDir string
SchemasDir string
SnapshotPath string
ConfigPath string
DSN string
}
Project owns an isolated PostgreSQL-backed test workspace.
func NewProject ¶
NewProject creates a temporary workspace and schema for integration tests.
func (*Project) BuildSchema ¶
BuildSchema parses the workspace models into an in-memory schema.
func (*Project) SaveSnapshot ¶
SaveSnapshot persists a schema snapshot for later drift checks.
Click to show internal directories.
Click to hide internal directories.