Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 697 Bytes

README.md

File metadata and controls

37 lines (25 loc) · 697 Bytes

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