User: Handle unique constraints errors (#101274)

* Handle unique constraints errors
This commit is contained in:
Karl Persson
2025-02-25 15:06:25 +01:00
committed by GitHub
parent 8d7108d774
commit c1d9d4d15a
2 changed files with 45 additions and 1 deletions
+13
View File
@@ -68,6 +68,19 @@ func TestIntegrationUserDataAccess(t *testing.T) {
require.NoError(t, err)
})
t.Run("error on duplicated user", func(t *testing.T) {
_, err := userStore.Insert(context.Background(),
&user.User{
Email: "test@email.com",
Name: "test1",
Login: "test1",
Created: time.Now(),
Updated: time.Now(),
},
)
require.ErrorIs(t, err, user.ErrUserAlreadyExists)
})
t.Run("get user", func(t *testing.T) {
_, err := userStore.GetByEmail(context.Background(),
&user.GetUserByEmailQuery{Email: "test@email.com"},