conformance

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WidgetModel = model.Definition{
	Name: "conformance_widget",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}},
		{Name: "name", Type: model.Text(), NotNull: true},
		{Name: "qty", Type: model.Int(), NotNull: true},
		{Name: "active", Type: model.Bool(), NotNull: true},
	},
}

Widget is the canonical record every backend is driven with. Its schema carries real DB metadata (types + PK) so SQL backends can CREATE TABLE it; mem ignores the metadata and stores by column name. Hand-written (conformance depends only on model, not ormc).

Functions

func Run

func Run(t *testing.T, f Factory)

Types

type Factory

type Factory struct {
	Name string
	New  func(t *testing.T, models ...model.Model) storage.Conn
}

Factory builds, for ONE clause, a fresh storage.Conn whose Widget table already exists and is EMPTY. Schema setup is the backend's job, done OUTSIDE this DML contract (this suite never builds a CreateTable Query):

  • mem: auto-creates the table on first Create — New just returns mem.New().
  • sqlite/postgres: New runs ddlc.ExportDDL(models) (or ddl.CreateTable) before returning.
  • indexdb: New declares `models` as IndexedDB object stores up front.

models are the record types the suite will exercise. Called once per clause → no cross-clause bleed.

type Widget

type Widget struct {
	Id     string
	Name   string
	Qty    int64
	Active bool
}

func (*Widget) DecodeFields

func (w *Widget) DecodeFields(r model.FieldReader)

func (*Widget) EncodeFields

func (w *Widget) EncodeFields(wr model.FieldWriter)

func (*Widget) IsNil

func (w *Widget) IsNil() bool

func (*Widget) ModelName

func (w *Widget) ModelName() string

func (*Widget) Pointers

func (w *Widget) Pointers() []any

func (*Widget) Schema

func (w *Widget) Schema() []model.Field

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL