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: 0

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