mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-30 21:20:04 +02:00
Move api/apitest
into the otel/oteltest
package (#1241)
* Move the apitest package into oteltest * Add documentation to exported func and type * Add changes to CHANGELOG * Update move in other modules
This commit is contained in:
parent
a46f88ee8d
commit
65044a118b
@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- Move the `go.opentelemetry.io/otel/api/trace/tracetest` package into `go.opentelemetry.io/otel/oteltest`. (#1229)
|
||||
- OTLP Exporter supports OTLP v0.5.0. (#1230)
|
||||
- The Sampler is now called on local child spans. (#1233)
|
||||
- Move test harness from the `go.opentelemetry.io/otel/api/apitest` package into `go.opentelemetry.io/otel/oteltest`. (#1241)
|
||||
- Rename `MergeItererator` to `MergeIterator` in the `go.opentelemetry.io/otel/label` package. (#1244)
|
||||
|
||||
### Removed
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package apitest provides utilities for testing.
|
||||
package apitest // import "go.opentelemetry.io/otel/api/apitest"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package apitest
|
||||
package oteltest
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -26,16 +26,21 @@ import (
|
||||
"go.opentelemetry.io/otel/label"
|
||||
)
|
||||
|
||||
// Harness is a testing harness used to test implementations of the
|
||||
// OpenTelemetry API.
|
||||
type Harness struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
// NewHarness returns an instantiated *Harness using t.
|
||||
func NewHarness(t *testing.T) *Harness {
|
||||
return &Harness{
|
||||
t: t,
|
||||
}
|
||||
}
|
||||
|
||||
// TestTracer runs validation tests for an implementation of the OpenTelemetry
|
||||
// Tracer API.
|
||||
func (h *Harness) TestTracer(subjectFactory func() otel.Tracer) {
|
||||
h.t.Run("#Start", func(t *testing.T) {
|
||||
t.Run("propagates the original context", func(t *testing.T) {
|
@ -23,7 +23,6 @@ import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/api/apitest"
|
||||
"go.opentelemetry.io/otel/internal/matchers"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/oteltest"
|
||||
@ -32,7 +31,7 @@ import (
|
||||
func TestTracer(t *testing.T) {
|
||||
tp := oteltest.NewTracerProvider()
|
||||
|
||||
apitest.NewHarness(t).TestTracer(func() func() otel.Tracer {
|
||||
oteltest.NewHarness(t).TestTracer(func() func() otel.Tracer {
|
||||
tp := oteltest.NewTracerProvider()
|
||||
var i uint64
|
||||
return func() otel.Tracer {
|
||||
|
@ -29,12 +29,12 @@ import (
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/oteltest"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/otel/api/apitest"
|
||||
ottest "go.opentelemetry.io/otel/internal/testing"
|
||||
export "go.opentelemetry.io/otel/sdk/export/trace"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
@ -59,7 +59,7 @@ func init() {
|
||||
|
||||
func TestTracerFollowsExpectedAPIBehaviour(t *testing.T) {
|
||||
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: TraceIDRatioBased(0)}))
|
||||
harness := apitest.NewHarness(t)
|
||||
harness := oteltest.NewHarness(t)
|
||||
subjectFactory := func() otel.Tracer {
|
||||
return tp.Tracer("")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user