testdb

package module
v0.0.0-...-bb9e844 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: MIT Imports: 8 Imported by: 0

README

Docker で立てたテスト用の RDB に対する操作が競合しないようにするためのアプローチとして、テストが実行されるパッケージ単位でランダムな名前のデータベースを生成して利用するサンプルコード。

テストの実行方法

direnv が必要。

cd example
direnv allow
docker compose up -d

ときたま失敗するパターン。 失敗しない場合は -count 10 の数を増やすと通りづらくなるはず。

go test -race -shuffle on -count 10 ./...

今回紹介するアプローチを使ったパターン。

TESTDB_ISOLATE=true go test -race -shuffle on -count 10 ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestWithMySQL

func TestWithMySQL() (*sqlx.DB, error)

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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