mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: catch constraint failures in delete operations (#2664)
This commit is contained in:
@@ -867,6 +867,11 @@ func Delete(t *testing.T, client *ent.Client) {
|
||||
affected, err = client.Node.Delete().Exec(ctx)
|
||||
require.NoError(err)
|
||||
require.Equal(3, affected)
|
||||
|
||||
info := client.GroupInfo.Create().SetDesc("group info").SaveX(ctx)
|
||||
client.Group.Create().SetInfo(info).SetName("GitHub").SetExpire(time.Now().Add(time.Hour)).ExecX(ctx)
|
||||
err = client.GroupInfo.DeleteOne(info).Exec(ctx)
|
||||
require.True(ent.IsConstraintError(err))
|
||||
}
|
||||
|
||||
func Relation(t *testing.T, client *ent.Client) {
|
||||
|
||||
Reference in New Issue
Block a user