Verify / verify (push) Canceled after 0s
抽取 Gin、配置、日志、数据库、Redis 与出站 HTTP 基础能力。 新增统一接入指南,将能力清单和相对链接检查纳入 make verify。 对齐远端 module 路径,修正 Redis 读写超时特殊值映射。 验证:make verify、make race-check 均通过。
26 lines
585 B
Go
26 lines
585 B
Go
package diagnostic
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestSnapshotPreservesCancellationAndCopiesValues(t *testing.T) {
|
|
parent, cancel := context.WithCancel(context.Background())
|
|
original := Snapshot{TraceID: "trusted"}
|
|
ctx := With(parent, original)
|
|
original.TraceID = "changed"
|
|
snapshot := From(ctx)
|
|
snapshot.TraceID = "local"
|
|
if From(ctx).TraceID != "trusted" {
|
|
t.Fatal("snapshot was modified")
|
|
}
|
|
cancel()
|
|
if ctx.Err() != context.Canceled {
|
|
t.Fatal("cancellation lost")
|
|
}
|
|
if From(context.Background()) != (Snapshot{}) {
|
|
t.Fatal("created fake diagnostics")
|
|
}
|
|
}
|