mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-11-24 08:22:25 +02:00
32 lines
605 B
Go
32 lines
605 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package otel
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
type testErrHandler struct {
|
|
err error
|
|
}
|
|
|
|
var _ ErrorHandler = &testErrHandler{}
|
|
|
|
func (eh *testErrHandler) Handle(err error) { eh.err = err }
|
|
|
|
func TestGlobalErrorHandler(t *testing.T) {
|
|
e1 := &testErrHandler{}
|
|
SetErrorHandler(e1)
|
|
Handle(assert.AnError)
|
|
assert.ErrorIs(t, e1.err, assert.AnError)
|
|
e1.err = nil
|
|
|
|
e2 := &testErrHandler{}
|
|
SetErrorHandler(e2)
|
|
GetErrorHandler().Handle(assert.AnError)
|
|
assert.ErrorIs(t, e2.err, assert.AnError)
|
|
}
|