init push

This commit is contained in:
2026-07-16 22:16:45 +07:00
commit 8b068bdb10
1021 changed files with 332816 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package service
import "testing"
func TestNormalizeSortByRules(t *testing.T) {
t.Run("field asc and desc", func(t *testing.T) {
if got := normalizeSortByRules("name", sortField("name")); got != "name ASC" {
t.Fatalf("unexpected asc sort: %q", got)
}
if got := normalizeSortByRules("-name", sortField("name")); got != "name DESC" {
t.Fatalf("unexpected desc sort: %q", got)
}
})
t.Run("alias and custom expression", func(t *testing.T) {
got := normalizeSortByRules("sort_order", sortExpr("sort_order ASC, created_at DESC", "sort_order DESC, created_at DESC", "sort_order"))
if got != "sort_order ASC, created_at DESC" {
t.Fatalf("unexpected custom sort: %q", got)
}
got = normalizeSortByRules("-hospital_name", sortField("hospital_name", "name", "hospital_name"))
if got != "hospital_name DESC" {
t.Fatalf("unexpected alias sort: %q", got)
}
})
t.Run("unknown", func(t *testing.T) {
if got := normalizeSortByRules("unknown", sortField("name")); got != "" {
t.Fatalf("expected empty for unknown, got %q", got)
}
})
}