- GET /payment-history/payments/{id}: single payment attempt with the raw
gateway_response (last HALKBANK JSON) for the "storage" icon modal
- GET /payment-history: sort (id/created_at/status/amount) and order
(asc/desc, default desc) query params
- GET /payment-history/{id}: order logs now newest first
- index on visa_master_order_payments (gateway_status, id DESC)
- regenerate swagger docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
738 B
Go
26 lines
738 B
Go
package db
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"online-back/internal/payment/paymenthistory"
|
|
)
|
|
|
|
func TestOrderByClause(t *testing.T) {
|
|
cases := []struct {
|
|
filter paymenthistory.ListFilter
|
|
want string
|
|
}{
|
|
{paymenthistory.ListFilter{Desc: true}, "p.id DESC"},
|
|
{paymenthistory.ListFilter{Sort: "id"}, "p.id ASC"},
|
|
{paymenthistory.ListFilter{Sort: "status", Desc: true}, "p.gateway_status DESC, p.id DESC"},
|
|
{paymenthistory.ListFilter{Sort: "amount"}, "p.amount_tmt ASC, p.id DESC"},
|
|
{paymenthistory.ListFilter{Sort: "p.id; DROP TABLE users", Desc: true}, "p.id DESC"},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := orderByClause(tc.filter); got != tc.want {
|
|
t.Errorf("orderByClause(%+v) = %q, want %q", tc.filter, got, tc.want)
|
|
}
|
|
}
|
|
}
|