Skip to content

Latest commit

 

History

History

sql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Venom - Executor SQL

Step to execute SQL queries into databases:

  • MySQL
  • PostgreSQL
  • Oracle
  • Sqlite

It use the package sqlx under the hood: https://github.com/jmoiron/sqlx to retrieve rows as a list of map[string]interface{}

Input

In your yaml file, you declare your step like this

  - driver mandatory [mysql/postgres/oracle/sqlite]
  - dsn mandatory
  - commands optional
  - file optional
  • commands is a list of SQL queries.
  • file parameter is only used as a fallback if commands is not used.

Example usage (mysql, oracle, SQLServer):

name: Title of TestSuite
testcases:

  - name: Query database
    steps:
      - type: sql
        driver: mysql
        dsn: user:password@(localhost:3306)/venom
        commands:
          - "SELECT * FROM employee;"
          - "SELECT * FROM person;"
        assertions:
          - result.queries.__Len__ ShouldEqual 2
          - result.queries.queries0.rows.rows0.name ShouldEqual Jack
          - result.queries.queries1.rows.rows0.age ShouldEqual 21

  - name: Oracle
    steps:
      - type: sql
        driver: oracle
        dsn: "oracle://system:oracle@localhost:49161/XE"
        commands:
          - select * from v$version

Example with a query file:

name: Title of TestSuite
testcases:

  - name: Query database
    steps:
      - type: sql
        database: mysql
        dsn: user:password@(localhost:3306)/venom
        file: ./test.sql
        assertions:
          - result.queries ShouldHaveLength 1

*note: in the example above, the results of each command is stored in the results array

SQL drivers

This executor uses the following SQL drivers: