Help us shape the future of Go! Take the 2026 Go Developer Survey

fakesql

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fakesql is a test stand-in for a rqlite engine (ADR-0233): one table todos(id, title, done), basic auth as user funcd, /db/query on a read-only connection and /db/execute?transaction all or nothing, in rqlite's array format. It understands only the statements the SQL tests send; any other is a syntax error, as an unknown table would be. NewStrict's engine starts with no table: a migration creates todos, and its _migrations table records versions (ADR-0236).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is a running fake engine.

func New

func New(t *testing.T, password string) *Engine

New starts a fake engine accepting user funcd with password; it stops at the end of t.

func NewStrict

func NewStrict(t *testing.T, password string) *Engine

NewStrict starts an engine with no table, which a migration must create.

func (*Engine) Addr

func (e *Engine) Addr() string

Addr is the engine's host:port, as the Engines registry records it.

func (*Engine) DDL

func (e *Engine) DDL() []string

DDL is every CREATE TABLE and ALTER TABLE applied, in order.

func (*Engine) Log

func (e *Engine) Log() []string

Log is every statement the engine ran or refused, in order.

func (*Engine) Migrations

func (e *Engine) Migrations() []string

Migrations are the versions in _migrations, in the order they were recorded.

func (*Engine) Paths

func (e *Engine) Paths() []string

Paths returns the request paths with their query, in order.

func (*Engine) Rows

func (e *Engine) Rows() []Todo

Rows returns a copy of the table.

func (*Engine) Seed

func (e *Engine) Seed(titles ...string)

Seed appends rows to the table.

type Todo

type Todo struct {
	ID    int64
	Title string
	Done  int64
}

Todo is one row of the fake's todos table.

Jump to

Keyboard shortcuts

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