dal/pkg/builder/convert_sort_test.go
Anton Nesterov 7f5c2a32cc
[ref] refactor adapter, add dialect registry for future extensibility
Signed-off-by: Anton Nesterov <anton@demiurg.io>
2024-08-15 09:06:29 +02:00

25 lines
415 B
Go

package builder
import (
"testing"
)
func TestConvertSort(t *testing.T) {
ctx := CommonDialect{
TableAlias: "t",
FieldName: "test",
}
result, err := convertSort(ctx, Map{
"a": -1,
"c": "desc",
"b": 1,
"d": nil,
})
if err != nil {
t.Error(err)
}
if result != `ORDER BY t.a DESC, t.b ASC, t.c DESC, t.d` {
t.Errorf("Expected ORDER BY t.a DESC, t.b ASC, t.c DESC, t.d, got %s", result)
}
}