mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-11 19:19:52 +08:00
- 查询结果页导出增加稳定兜底,异常时确保 loading 关闭避免持续转圈 - DataGrid 导出逻辑按数据源能力分流,优先走后端 ExportQuery 并保留结果集导出降级 - QueryEditor 传递结果导出 SQL,保证查询结果导出范围与当前结果一致 - 后端补充 ExportData/ExportQuery 关键日志,提升导出链路可观测性
33 lines
781 B
Go
33 lines
781 B
Go
package db
|
||
|
||
import (
|
||
"context"
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
func TestTimeoutMsFromContext_NoDeadline(t *testing.T) {
|
||
if got := timeoutMsFromContext(context.Background()); got != 0 {
|
||
t.Fatalf("无 deadline 时应返回 0,got=%d", got)
|
||
}
|
||
}
|
||
|
||
func TestTimeoutMsFromContext_WithDeadline(t *testing.T) {
|
||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||
defer cancel()
|
||
|
||
got := timeoutMsFromContext(ctx)
|
||
if got <= 0 {
|
||
t.Fatalf("有 deadline 时应返回正值,got=%d", got)
|
||
}
|
||
}
|
||
|
||
func TestTimeoutMsFromContext_ExpiredDeadline(t *testing.T) {
|
||
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-time.Second))
|
||
defer cancel()
|
||
|
||
if got := timeoutMsFromContext(ctx); got != 1 {
|
||
t.Fatalf("过期 deadline 应返回 1,got=%d", got)
|
||
}
|
||
}
|