From 43b8fc4df2b254fc0f8fa00e08c20c53214299be Mon Sep 17 00:00:00 2001 From: steebchen Date: Sat, 28 Oct 2023 05:26:22 +0400 Subject: [PATCH] test sqlite --- test/errors/unique/unique_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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) }, }}