You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-25 22:41:46 +02:00
refactor: replace context.Background() with t.Context()/b.Context() in tests (#7352)
Based on the Go version we currently use, the dependency already supports 1.24+, which allows using `t.Context()` and `b.Context()` in unit tests and benchmarks respectively. - Enable `context-background` and `context-todo` in [`usetesting`](https://golangci-lint.run/docs/linters/configuration/#usetesting) - Adjust the code to support linter detection --------- Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Tyler Yahn <codingalias@gmail.com> Co-authored-by: Damien Mathieu <42@dmathieu.com>
This commit is contained in:
@@ -45,27 +45,27 @@ func TestSpanFromContext(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "background context",
|
||||
context: context.Background(),
|
||||
context: t.Context(),
|
||||
expectedSpan: emptySpan,
|
||||
},
|
||||
{
|
||||
name: "local span",
|
||||
context: ContextWithSpan(context.Background(), localSpan),
|
||||
context: ContextWithSpan(t.Context(), localSpan),
|
||||
expectedSpan: localSpan,
|
||||
},
|
||||
{
|
||||
name: "remote span",
|
||||
context: ContextWithSpan(context.Background(), remoteSpan),
|
||||
context: ContextWithSpan(t.Context(), remoteSpan),
|
||||
expectedSpan: remoteSpan,
|
||||
},
|
||||
{
|
||||
name: "wrapped remote span",
|
||||
context: ContextWithRemoteSpanContext(context.Background(), remoteSpan.SpanContext()),
|
||||
context: ContextWithRemoteSpanContext(t.Context(), remoteSpan.SpanContext()),
|
||||
expectedSpan: wrappedSpan,
|
||||
},
|
||||
{
|
||||
name: "wrapped local span becomes remote",
|
||||
context: ContextWithRemoteSpanContext(context.Background(), localSpan.SpanContext()),
|
||||
context: ContextWithRemoteSpanContext(t.Context(), localSpan.SpanContext()),
|
||||
expectedSpan: wrappedSpan,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user