mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-16 09:52:40 +08:00
- 完善慢查询采集、聚合、迁移与跨进程持久化 - 加固只读诊断边界并补齐多数据库执行计划解析 - 优化慢 SQL 面板、计划图、响应式布局与交互体验 - 补充后端、前端及 SQL Server 会话回归测试
32 lines
789 B
Go
32 lines
789 B
Go
package connection
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestQueryExecutionRecordJSONIncludesFalseDiagnosable(t *testing.T) {
|
|
record := QueryExecutionRecord{
|
|
SQLText: "UPDATE users SET active = 1",
|
|
Diagnosable: false,
|
|
StatementCount: 1,
|
|
}
|
|
|
|
payload, err := json.Marshal(record)
|
|
if err != nil {
|
|
t.Fatalf("json.Marshal returned error: %v", err)
|
|
}
|
|
|
|
var fields map[string]any
|
|
if err := json.Unmarshal(payload, &fields); err != nil {
|
|
t.Fatalf("json.Unmarshal returned error: %v", err)
|
|
}
|
|
diagnosable, ok := fields["diagnosable"]
|
|
if !ok {
|
|
t.Fatalf("diagnosable=false must be included in the frontend payload: %s", payload)
|
|
}
|
|
if value, ok := diagnosable.(bool); !ok || value {
|
|
t.Fatalf("diagnosable must be the boolean false, got %#v", diagnosable)
|
|
}
|
|
}
|