sqltestdb

package
v0.0.0-...-fa1d755 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Skipped = fmt.Errorf("skipped")

Functions

func RunTests

func RunTests(dir string, run Runner, report Reporter, dialect Dialect, update, psql bool) error

RunTests runs all of the tests in a directory: <dir>/sql/*.sql contains the tests and <dir>/expected/*.out contains the expected output for each sql file. The output from each sql file will get written to <dir>/output/*.out.

Types

type DBRunner

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

func (*DBRunner) Close

func (dbr *DBRunner) Close() error

func (*DBRunner) Connect

func (dbr *DBRunner) Connect(driver, source string) error

func (*DBRunner) RunExec

func (run *DBRunner) RunExec(tst *Test) (int64, error)

func (*DBRunner) RunQuery

func (run *DBRunner) RunQuery(tst *Test) (QueryResult, error)

type DefaultDialect

type DefaultDialect struct{}

DefaultDialect provides default behavior; most implementation specific dialects can be based on this one.

func (DefaultDialect) ColumnType

func (_ DefaultDialect) ColumnType(typ string) string

func (DefaultDialect) ColumnTypeArg

func (_ DefaultDialect) ColumnTypeArg(typ string, arg int) string

type Dialect

type Dialect interface {
	// DriverName is the name of the dialect; eg. postgres.
	DriverName() string
	// ColumnType maps a particular type into something that the implementation understands.
	ColumnType(typ string) string
	// ColumnTypeArg maps a particular type with an argument into something that the
	// implementation understands.
	ColumnTypeArg(typ string, arg int) string
}

Dialect specifies the behavior of a particular SQL implementation.

type QueryResult

type QueryResult struct {
	Columns   []string
	TypeNames []string
	Rows      [][]string
}

type Reporter

type Reporter interface {
	// Report on the results of a single test.
	Report(test string, err error) error
}

type Runner

type Runner interface {
	// RunExec is used to execute a single SQL statement which must not return rows.
	RunExec(tst *Test) (int64, error)
	// RunQuery is used to execute a single SQL statement which returns a slice of column
	// names and a slice of rows.
	RunQuery(tst *Test) (QueryResult, error)
}

type Scanner

type Scanner struct {
	Filename string
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (*Test, error)

type TemplateContext

type TemplateContext struct {
	Global TestContext
	Skip   bool
	// contains filtered or unexported fields
}

func NewTemplateContext

func NewTemplateContext(dialect Dialect) *TemplateContext

func (*TemplateContext) Execute

func (tmplCtx *TemplateContext) Execute(tmpl string) (string, TestContext, error)

type Test

type Test struct {
	Filename   string
	LineNumber int
	Test       string
	Statement  string
}

type TestContext

type TestContext struct {
	Statement string
	Fail      bool
	NoSort    bool
	Types     bool
}

Jump to

Keyboard shortcuts

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