testutils

package
v0.0.0-...-76439fa Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateUserTable creates user table
	CreateUserTable = `CREATE TABLE MUser (
		id        SERIAL,
		w_name	  varchar(255) NOT NULL,
		w_id      varchar(255) PRIMARY KEY
	);`
	// CreateGroupTable creates group table
	CreateGroupTable = `CREATE TABLE MGroup (
		id          SERIAL PRIMARY KEY,
		name        varchar(255) NOT NULL,
		description text
	);`
	// CreateBelongToTable creates belong to table
	CreateBelongToTable = `` /* 282-byte string literal not displayed */

	// CreateRecordTable creates record table
	CreateRecordTable = `` /* 429-byte string literal not displayed */

	// CreateHistoryTable creates history table
	CreateHistoryTable = `` /* 311-byte string literal not displayed */

	// DropUserTable drops user talbe
	DropUserTable = `DROP TABLE muser`
	// DropGroupTable drops group talbe
	DropGroupTable = `DROP TABLE mgroup`
	// DropBelongToTable drops belong to talbe
	DropBelongToTable = `DROP TABLE belongto`
	// DropRecordTable drops record talbe
	DropRecordTable = `DROP TABLE record`
	// DropHistoryTable drops history talbe
	DropHistoryTable = `DROP TABLE history`
	// RecordTableClear clears record table
	RecordTableClear = `DELETE FROM Record`
	// UserTableClear clears user table
	UserTableClear = `DELETE FROM MUser`
	// GroupTableClear clears group table
	GroupTableClear = `DELETE FROM MGroup`
	// InsertUserA inserts a sample user A
	InsertUserA = `INSERT INTO MUser (w_name, w_id) VALUES ('test user1', '12345u')`
	// InsertUserB inserts a sample user B
	InsertUserB = `INSERT INTO MUser (w_name, w_id) VALUES ('test user2', '23456u')`
	// InsertUserC inserts a sample user C
	InsertUserC = `INSERT INTO MUser (w_name, w_id) VALUES('test user3', '34567u')`
	// InsertGroupA inserts a sample group A
	InsertGroupA = `INSERT INTO MGroup (name, description) VALUES('292 Pasir Panjang Road', 'This is just a test group')`
	// InsertRecordOne inserts a sample record
	InsertRecordOne = `` /* 180-byte string literal not displayed */
	// InsertRecordTwo inserts a sample record
	InsertRecordTwo = `` /* 180-byte string literal not displayed */
	// InsertRecordThree inserts a sample record
	InsertRecordThree = `` /* 169-byte string literal not displayed */
	// ResetUserSeq resets user sequence
	ResetUserSeq = `ALTER SEQUENCE muser_id_seq RESTART;`
	// ResetGroupSeq resets group sequence
	ResetGroupSeq = `ALTER SEQUENCE mgroup_id_seq RESTART;`
	// ResetRecordSeq resets group sequence
	ResetRecordSeq = `ALTER SEQUENCE record_id_seq RESTART;`
)

Variables

This section is empty.

Functions

func CheckResponseCode

func CheckResponseCode(t *testing.T, expected, actual int)

CheckResponseCode checks response code equal

func CreateTables

func CreateTables(db database.Database)

CreateTables creates all required tables

func DropAllTables

func DropAllTables(db database.Database)

DropAllTables Drops all tables in database

func ExecuteRequest

func ExecuteRequest(req *http.Request, app application.App) *httptest.ResponseRecorder

ExecuteRequest executes a http request

func InsertGroups

func InsertGroups(db database.Database)

InsertGroups inserts 1 test group

func InsertRecords

func InsertRecords(db database.Database)

InsertRecords inserts 3 test records

func InsertUsers

func InsertUsers(db database.Database)

InsertUsers inserts 3 test users

Types

This section is empty.

Jump to

Keyboard shortcuts

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