Skip to content

Commit

Permalink
logtest: AssertRecordEqual checks EventName
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Jan 21, 2025
1 parent aac684c commit e01aace
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions log/logtest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
func AssertRecordEqual(t testing.TB, want, got log.Record) bool {
t.Helper()

if want.EventName() != got.EventName() {
t.Errorf("EventName value is not equal:\nwant: %v\ngot: %v", want.EventName(), got.EventName())
return false
}
if !want.Timestamp().Equal(got.Timestamp()) {
t.Errorf("Timestamp value is not equal:\nwant: %v\ngot: %v", want.Timestamp(), got.Timestamp())
return false
Expand Down
5 changes: 3 additions & 2 deletions log/logtest/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
func TestAssertRecord(t *testing.T) {
r1 := log.Record{}
r2 := log.Record{}
now := time.Now()

AssertRecordEqual(t, r1, r2)

now := time.Now()
r1.SetEventName("my event")
r2.SetEventName("my event")
r1.SetTimestamp(now)
r2.SetTimestamp(now)
r1.SetObservedTimestamp(now)
Expand Down

0 comments on commit e01aace

Please sign in to comment.