1
0
mirror of https://github.com/xorcare/testing-go-code-with-postgres.git synced 2025-06-30 23:23:40 +02:00

Add parallel running for tests

This commit is contained in:
Vasiliy Vasilyuk
2023-07-05 07:54:01 +03:00
parent fd50c57aff
commit 9cb6ced6ef

View File

@ -20,6 +20,8 @@ func TestUserRepository_CreateUser(t *testing.T) {
t.Skip("skipping test in short mode")
}
t.Parallel()
newFullyFiledUser := func() User {
return User{
ID: uuid.New(),
@ -29,6 +31,8 @@ func TestUserRepository_CreateUser(t *testing.T) {
}
t.Run("Successfully created a User", func(t *testing.T) {
t.Parallel()
// Arrange
postgres := testingpg.New(t)
repo := NewUserRepository(postgres.PgxPool())
@ -48,6 +52,8 @@ func TestUserRepository_CreateUser(t *testing.T) {
})
t.Run("Cannot create a user with the same ID", func(t *testing.T) {
t.Parallel()
// Arrange
postgres := testingpg.New(t)
repo := NewUserRepository(postgres.PgxPool())
@ -71,7 +77,11 @@ func TestUserRepository_ReadUser(t *testing.T) {
t.Skip("skipping test in short mode")
}
t.Parallel()
t.Run("Get an error if the user does not exist", func(t *testing.T) {
t.Parallel()
// Arrange
postgres := testingpg.New(t)
repo := NewUserRepository(postgres.PgxPool())