What to test
A deadlock always self-resolves: Postgres's background deadlock detector wakes after `deadlock_timeout` (1 second by default) of waiting, finds the wait cycle, and aborts one of the two transactions so the other can proceed. By the time you're reading the error, it's already over — there is nothing 'stuck' left to kill. What's left to do is find out why the two transactions waited on each other and stop it recurring.