Skip to content

Commit

Permalink
test sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Oct 28, 2023
1 parent 820d2a4 commit 43b8fc4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/errors/unique/unique_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]"),
User.Username.Set("username"),
).Exec(ctx)
assert.Equal(t, nil, err)

_, err = client.User.CreateOne(
User.Email.Set("[email protected]"),
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)
},
}}
Expand Down

0 comments on commit 43b8fc4

Please sign in to comment.