diff --git a/test/errors/unique/unique_test.go b/test/errors/unique/unique_test.go index 62f43948b..6eba0e997 100644 --- a/test/errors/unique/unique_test.go +++ b/test/errors/unique/unique_test.go @@ -64,6 +64,29 @@ func TestUniqueConstraintViolation(t *testing.T) { // }, violation) assert.Equal(t, "User_email_key", violation.Key) + assert.Equal(t, true, ok) + }, + }, { + name: "sqlite unique constraint violation", + dbs: []test.Database{test.SQLite}, + run: func(t *testing.T, client *PrismaClient, ctx cx) { + _, err := client.User.CreateOne( + User.Email.Set("john@example.com"), + User.Username.Set("username"), + ).Exec(ctx) + assert.Equal(t, nil, err) + + _, err = client.User.CreateOne( + User.Email.Set("john@example.com"), + User.Username.Set("username"), + ).Exec(ctx) + + violation, ok := IsUniqueConstraint(err) + // assert.Equal(t, &ErrUniqueConstraint{ + // Field: User.Email.Field(), + // }, violation) + assert.Equal(t, User.Email.Field(), violation.Fields[0]) + assert.Equal(t, true, ok) }, }}