Skip to content

A CLI tool used to create unit testing framework for SQL in GitHub repositories. This works by generating a GitHub Actions workflow file, which runs tests against a dockerized database. The tool is open-source and completely free (including the GitHub-managed machines the tests run on).

Notifications You must be signed in to change notification settings

ThugPigeon653/testQL-source

Repository files navigation

TestQL - SQL unit testing made easy

TestQL - SQL unit testing made easy


💡 A CLI for creating unit tests and GitHub Actions workflows for SQL unit testing.

Table of Contents

See intro video: https://youtu.be/3Biv_cqomlk

What is TestQL?

  • This tool provides a simple solution, for unit testing SQL files before they reach your main repository. By using TestQL, you can add SQL unit tests to your repository, without actually having to provision infrastructure or write any code.
  • TestQL is a CLI tool that generates unit tests and workflows, which test SQL at the source-code level. The tool acheives this by generating all code required to test your SQL against a GitHub managed database - including provisioning of test infrastructure, dependancy management, and database connection.
  • Unit tests are generated on-demand, and run automatically every time a 'push' is made to the repository. This makes working on SQL repositories highly agile, because unit tests are being run for every commit.
  • See example implementation at https://github.com/ThugPigeon653/sql-mulitilanguage

Installation

Windows:

  • NOTE: A second installer will be provided soon, which does not require a python installation to run.
  • Make sure you have a valid installation of Python
  • Clone the repository: https://github.com/ThugPigeon653/testQL-source.git
  • Extract files: Extract files to any location you wish - the location will not affect the tools functionality
  • Build and install: Run 'Build.bat' in the root of your newly extracted directory as admin

Linux:

Getting started

  • Create the repo: Initialize or clone a repository to a local destination of your choosing. This is the repository which does/will contain your SQL files.
  • Open a terminal in the root folder of your cloned repository
  • Run the init command: 'testql init'. By default, this command will assume you are using postgres

Commands

  • Note: [a,b|c] indicates that 'a' and 'b' are equivelant, while 'a' and 'c' are alternative choices.

Initialize:

  • testql init --engine [ postgres, pg, postgresql | tsql | mysql] This command sets up unit tests and a workflow file, using your chosen database engine

Contributing

Everyone is welcome to contribute at any time. I have implemented a few rules on the repository, but otherwise it is really straightforward. It is recommended to have some experience or knowledge of GitHub Actions before jumping in (and probably Python)

  • Clone this repo to your desired install destination. Currently, it is installed and developed in the same location.
  • Checkout a new branch (git checkout -b ). It can be any branch, just not 'main'.
  • PR: Once you have pushed some changes, open a Pull Request - thats it!

Note: Don't alter the workflow file, or push to main branch. Either of these things will automatically reject all changes.

About

A CLI tool used to create unit testing framework for SQL in GitHub repositories. This works by generating a GitHub Actions workflow file, which runs tests against a dockerized database. The tool is open-source and completely free (including the GitHub-managed machines the tests run on).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published