package observe import ( "context" "testing" ) type testKey struct{} func TestEnsureSharesOneRequestAndRecordsTheProblem(t *testing.T) { RecordProblem(context.Background(), "internal") // no Request: no effect, no panic ctx, first := Ensure(context.Background()) nested, second := Ensure(context.WithValue(ctx, testKey{}, "other value")) if first != second { t.Fatal("Ensure() created a second Request for the same request") } RecordProblem(nested, "not_found") if got := first.ProblemCode(); got != "not_found" { t.Fatalf("ProblemCode() = %q, want not_found", got) } }