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 ./... Expand ▾ Collapse ▴ Documentation ¶ Index ¶ func TestWithMySQL() (*sqlx.DB, error) Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func TestWithMySQL ¶ func TestWithMySQL() (*sqlx.DB, error) Types ¶ This section is empty. Source Files ¶ View all Source files mysql.go testdb.go Directories ¶ Show internal Expand all Path Synopsis example cmd/server handler model repository repository/mysql Click to show internal directories. Click to hide internal directories.