Skip to content

[assert] Diff doesn't display pointer vs nil in time.Time #372

@tobbbles

Description

@tobbbles

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)},

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions