Skip to content

Commit

Permalink
Move api/apitest into the otel/oteltest package (#1241)
Browse files Browse the repository at this point in the history
* Move the apitest package into oteltest

* Add documentation to exported func and type

* Add changes to CHANGELOG

* Update move in other modules
  • Loading branch information
MrAlias committed Oct 12, 2020
1 parent a46f88e commit 65044a1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions api/apitest/doc.go

This file was deleted.

7 changes: 6 additions & 1 deletion api/apitest/harness.go → oteltest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package apitest
package oteltest

import (
"context"
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions oteltest/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions sdk/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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("")
}
Expand Down

0 comments on commit 65044a1

Please sign in to comment.