modeltest

package
v0.0.0-...-ae36b9e Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

modeltest provides functions to create database fixtures for unit test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAllTables

func LoadAllTables(t *testing.T, db *sql.DB, dbName string) ([]string, error)

func NewTodo

func NewTodo(setters ...func(*model.Todo)) *model.Todo

NewTodo returns `*model.Todo` with setters function to specify field value for *model.Todo.

func RandomString

func RandomString(length int) string

RandomString creates random string of alphabet and number with given length.

func TruncateAllTables

func TruncateAllTables(t *testing.T, db *sql.DB, dbName string)

TruncateAllTables truncates all tables of the database. You need to call this function to remove all rows to ensure your test starts with clean database.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL