1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

log/logtest: change AssertEqual to accept TestingT for benchmark support (#6908)

This commit is contained in:
Flc゛
2025-07-07 18:13:53 +08:00
committed by GitHub
parent bd26298747
commit 186bd18db4
3 changed files with 19 additions and 13 deletions
+4 -10
View File
@@ -5,7 +5,6 @@ package logtest // import "go.opentelemetry.io/otel/log/logtest"
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
@@ -13,19 +12,14 @@ import (
"go.opentelemetry.io/otel/log"
)
// AssertEqual asserts that the two concrete data-types from the logtest package are equal.
func AssertEqual[T Recording | Record](t *testing.T, want, got T, opts ...AssertOption) bool {
t.Helper()
return assertEqual(t, want, got, opts...)
}
// testingT reports failure messages.
// TestingT reports failure messages.
// *testing.T implements this interface.
type testingT interface {
type TestingT interface {
Errorf(format string, args ...any)
}
func assertEqual[T Recording | Record](t testingT, want, got T, opts ...AssertOption) bool {
// AssertEqual asserts that the two concrete data-types from the logtest package are equal.
func AssertEqual[T Recording | Record](t TestingT, want, got T, opts ...AssertOption) bool {
if h, ok := t.(interface{ Helper() }); ok {
h.Helper()
}