dbfixtures

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

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
  - 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.

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

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.

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