dbfixtures

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 5

README

Venom - Executor Database Fixtures

Step to load fixtures into MySQL and PostgreSQL databases.

It uses the package testfixtures/v3 under the hood: https://github.com/go-testfixtures/testfixtures Please read its documentation for further details about the parameters of this executor, especially folder and files, and how you should write the fixtures.

Input

In your yaml file, you declare your step like this

  - database mandatory [mysql/postgres/sqlite3]
  - dsn mandatory
  - schemas optional
  - migrations optional
  - migrationsTable optional
  - skipResetSequences optional
  - files optional
  - folder optional
  • schemas is a list of paths to several .sql file that contains the schemas of the tables in your database. If specified, the content of every file will be executed before loading the fixtures.
  • files parameter is only used as a fallback if folder is not used.
  • migrations is a folder path that contains SQL migrations files that can be used to initialize the database, instead of a list of schemas. Note that if schemas is not empty, it will have precedence and migrations files will be ignored.
  • migrationsTable is the table used to store the migration version.
  • skipResetSequences is only used for PostgreSQL database, it control whether index should be reset (default) or not

Example usage (mysql):


name: Title of TestSuite
testcases:

  - name: Load database fixtures
    steps:
      - type: dbfixtures
        database: mysql
        dsn: user:password@(localhost:3306)/venom?multiStatements=true
        schemas:
          - schemas/mysql.sql
        folder: fixtures
        files:
          - fixtures/table.yml

note: in the example above, the query param multiStatements=true is mandatory if we want to be able to load the schema.

SQL drivers

This executor uses the following SQL drivers:

Documentation

Index

Constants

View Source
const Name = "dbfixtures"

Name of the executor.

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new executor that can load database fixtures.

Types

type Executor

type Executor struct {
	Files              []string `json:"files" yaml:"files"`
	Folder             string   `json:"folder" yaml:"folder"`
	Database           string   `json:"database" yaml:"database"`
	DSN                string   `json:"dsn" yaml:"dsn"`
	Schemas            []string `json:"schemas" yaml:"schemas"`
	Migrations         string   `json:"migrations" yaml:"migrations"`
	MigrationsTable    string   `json:"migrationsTable" yaml:"migrationsTable"`
	SkipResetSequences bool     `json:"skipResetSequences" yaml:"skipResetSequences"`
}

Executor is a venom executor that can load fixtures in many databases, using YAML schemas.

func (Executor) GetDefaultAssertions

func (e Executor) GetDefaultAssertions() venom.StepAssertions

GetDefaultAssertions return the default assertions of the executor.

func (Executor) Run

func (e Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, error)

Run implements the venom.Executor interface for Executor.

func (Executor) ZeroValueResult added in v0.17.0

func (Executor) ZeroValueResult() interface{}

ZeroValueResult return an empty implementation of this executor result

type Result

type Result struct {
	Executor Executor `json:"executor,omitempty" yaml:"executor,omitempty"`
}

Result represents a step result.

Jump to

Keyboard shortcuts

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