testutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertResponse

func AssertResponse(t *testing.T, got *http.Response, status int, body []byte)

テストのアサーション関数 @params t テストユーティリティ got 実際のレスポンス status wantレスポンスステータスコード body wantレスポンスボディ

func LoadFile

func LoadFile(t *testing.T, path string) []byte

JSONファイルの読み込み

func NewDBForMock

func NewDBForMock(t *testing.T) (*sqlx.DB, sqlmock.Sqlmock)

NewDBForTest はテスト用のDBを作成する

実際にはDBには接続しない

func NewTxForMock

func NewTxForMock(t *testing.T, ctx context.Context) *sqlx.Tx

NewTxForMock はモック用のトランザクションを作成する

実際にはDBには接続しない

begin, commitは正常系を返すようにモックする 異常系をテストしたい場合は、NewDBForMockを使って自分でモックを作成する

func OpenDBForTest

func OpenDBForTest(t *testing.T) *sqlx.DB

テストにおいてデータベース接続する 実際にデーターベース接続する

Types

This section is empty.

Jump to

Keyboard shortcuts

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