Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions log/logtest/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
)

// 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...)
func AssertEqual[T Recording | Record](tb testing.TB, want, got T, opts ...AssertOption) bool {
tb.Helper()
return assertEqual(tb, want, got, opts...)
}

// testingT reports failure messages.
Expand Down
16 changes: 16 additions & 0 deletions log/logtest/assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ func TestAssertEqual(t *testing.T) {
assert.True(t, got, "expected recordings to be equal")
}

func BenchmarkAssertEqual(b *testing.B) {
Comment thread
flc1125 marked this conversation as resolved.
Outdated
ar := Recording{
Scope{Name: b.Name()}: []Record{
{Body: log.StringValue("msg"), Attributes: []log.KeyValue{log.String("foo", "bar"), log.Int("n", 1)}},
},
}
br := Recording{
Scope{Name: b.Name()}: []Record{
{Body: log.StringValue("msg"), Attributes: []log.KeyValue{log.Int("n", 1), log.String("foo", "bar")}},
},
}

got := AssertEqual(b, ar, br)
assert.True(b, got, "expected recordings to be equal")
}

func TestAssertEqualRecording(t *testing.T) {
tests := []struct {
name string
Expand Down