dbfixtures

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: BSD-3-Clause Imports: 10 Imported by: 5

README

Venom - Executor Database Fixtures

Step to load fixtures into MySQL and PostgreSQL databases.

It use the package testfixtures.v2 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 tour step like this

  - database mandatory [mysql/postgres]
  - dsn mandatory
  - schemas optional
  - migrations 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.

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"`
}

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(testCaseContext venom.TestCaseContext, l venom.Logger, step venom.TestStep) (venom.ExecutorResult, error)

Run implements the venom.Executor interface for Executor.

func (Executor) ZeroValueResult added in v0.17.0

func (Executor) ZeroValueResult() venom.ExecutorResult

ZeroValueResult return an empty implemtation 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