[assert] Diff doesn't display pointer vs nil in time.Time
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go
- Domain
- testing-qa
Research direction
Start by reproducing the reported assert.Equal and assert.EqualValues comparison with time.Time values whose *time.Location is nil versus initialized. Inspect the assertion diff output path and make the completed behavior show this distinction in the diff, then verify the original example no longer produces an empty Diff section.
Written by the indexing model from the issue text.
Description
When using assert.Equal(t, x, y) and assert.EqualValues(t, x, y), I run into the following issue where it errors but no diff is displayed. After digging down I discovered it's to do with time.Time and whether *time.Location is initialised.
Output from assert:
Error Trace: store_test.go:70
Error: Not equal:
expected: []*cache.Item{(*cache.Item)(0xc4201a2640), (*cache.Item)(0xc4201a2780)}
received: []*cache.Item{(*cache.Item)(0xc42021e000), (*cache.Item)(0xc42021e140)}
Diff:
Logging out the structs with "%#v" reveals the difference is in time.Time. See my manual diff below:
- ExpiresAt:time.Time{sec:0, nsec:0, loc:(*time.Location)(nil)},
+ ExpiresAt:time.Time{sec:0, nsec:0, loc:(*time.Location)(0x8bb580)},
- Dominant language
- Go
- Stars
- 26.2k
- Forks
- 1.9k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stretchr/testify
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
internal/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in stretchr/testify
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100