| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package opencensus // import "go.opentelemetry.io/otel/bridge/opencensus" |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
|
| 11 |
"go.opentelemetry.io/otel" |
| 12 |
"go.opentelemetry.io/otel/trace/noop" |
| 13 |
) |
| 14 |
|
| 15 |
func TestNewTraceConfig(t *testing.T) { |
| 16 |
globalTP := noop.NewTracerProvider() |
| 17 |
customTP := noop.NewTracerProvider() |
| 18 |
otel.SetTracerProvider(globalTP) |
| 19 |
for _, tc := range []struct { |
| 20 |
desc string |
| 21 |
opts []TraceOption |
| 22 |
expected traceConfig |
| 23 |
}{ |
| 24 |
{ |
| 25 |
desc: "default", |
| 26 |
expected: traceConfig{ |
| 27 |
tp: globalTP, |
| 28 |
}, |
| 29 |
}, |
| 30 |
{ |
| 31 |
desc: "overridden", |
| 32 |
opts: []TraceOption{ |
| 33 |
WithTracerProvider(customTP), |
| 34 |
}, |
| 35 |
expected: traceConfig{ |
| 36 |
tp: customTP, |
| 37 |
}, |
| 38 |
}, |
| 39 |
} { |
| 40 |
t.Run(tc.desc, func(t *testing.T) { |
| 41 |
cfg := newTraceConfig(tc.opts) |
| 42 |
assert.Equal(t, tc.expected, cfg) |
| 43 |
}) |
| 44 |
} |
| 45 |
} |