Categorygithub.com/partyzanex/testutils
repositorypackage
0.1.1
Repository: https://github.com/partyzanex/testutils.git
Documentation: pkg.go.dev

# README

testutils

Test toolkit for simplify the development of tests on Go

This package contains universal interfaces and utilities for handling errors in tests and benchmarks

Example

package some_test

import (
	"testing"
	"time"

	_ "github.com/go-sql-driver/mysql"
	
	"github.com/partyzanex/testutils"
)

func TestSomeTestName(t *testing.T) {
	// supported mysql and postgres
	db := testutils.NewSqlDB(t, "postgres", "TEST_DSN")

	rows, err := db.Query(`select id, name from tbl where dt > ?`, time.Now())
	testutils.FatalErr(t, "db.Query", err)

	// ...
}

Run:

export TEST_DSN="user=postgres password=password sslmode=disable dbname=testdb"

go test ./path/to/some -v