package catalog import ( "context" "errors" "io" "testing" "github.com/jackc/pgx/v5/pgconn" ) func TestRetryable(t *testing.T) { cases := []struct { err error want bool }{ {&pgconn.PgError{Code: "40001"}, true}, // sérialisation {&pgconn.PgError{Code: "40P01"}, true}, // interblocage {&pgconn.PgError{Code: "25006"}, true}, // secondaire après bascule {&pgconn.PgError{Code: "57P01"}, true}, // arrêt du serveur {&pgconn.PgError{Code: "23505"}, false}, // doublon : erreur métier {io.ErrUnexpectedEOF, true}, {context.Canceled, false}, {errors.New("autre"), false}, } for _, c := range cases { if got := Retryable(c.err); got != c.want { t.Errorf("Retryable(%v) = %v, veut %v", c.err, got, c.want) } } }