Files
online-backend/internal/payment/paymenthistory/db/order_test.go
GuwandykA a715cd23ea
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
payment-history: payment detail with GBÜS response, sorting, newest-first logs
- 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>
2026-10-24 13:32:36 +05:00

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)
}
}
}