tests

package
v0.0.0-...-1f850de Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Query_GetUserByID       = `SELECT * FROM "users" WHERE id = $1 AND "users"."deleted_at" IS NULL ORDER BY "users"."id" LIMIT 1`
	Query_GetUserByUsername = `SELECT * FROM "users" WHERE username = $1 AND "users"."deleted_at" IS NULL ORDER BY "users"."id" LIMIT 1`

	Query_GetTodos          = `SELECT * FROM "todos" WHERE "todos"."deleted_at" IS NULL`
	Query_GetTodoByID       = `SELECT * FROM "todos" WHERE id = $1 AND "todos"."deleted_at" IS NULL ORDER BY "todos"."id" LIMIT 1`
	Query_GetTodosByOwnerID = `SELECT * FROM "todos" WHERE owner_id = $1 AND "todos"."deleted_at" IS NULL`

	Query_CreateTodo = `` /* 136-byte string literal not displayed */
	Query_DeleteTodo = `UPDATE "todos" SET "deleted_at"=$1 WHERE "todos"."id" = $2 AND "todos"."deleted_at" IS NULL`
	Query_UpdateTodo = `` /* 158-byte string literal not displayed */
)

These are queries executed by GORM for the corresponding actions. They are useful for unit testing with sqlmock.

Variables

This section is empty.

Functions

func DBMocks

func DBMocks() (*gorm.DB, *sql.DB, sqlmock.Sqlmock)

func EngineMock

func EngineMock() *gin.Engine

func HTTPMocks

func HTTPMocks() (*httptest.ResponseRecorder, *gin.Context, *gin.Engine)

func PerformRequest

func PerformRequest(r http.Handler, method, path string, body io.Reader) *httptest.ResponseRecorder

func PerformRequestBasic

func PerformRequestBasic(r http.Handler, req *http.Request) *httptest.ResponseRecorder

func PerformRequestWithHeaders

func PerformRequestWithHeaders(r http.Handler, method, path string, body io.Reader, headers map[string]string) *httptest.ResponseRecorder

Types

type AnyTime

type AnyTime struct{}

match any time argument in the arguments see: https://pkg.go.dev/github.com/DATA-DOG/go-sqlmock#readme-matching-arguments-like-time-time

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

satisfies sqlmock.Argument interface

Jump to

Keyboard shortcuts

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