Hi all,
I’m at a loss. I’m running an integration test with google cloud datastore, and occasionally I will receive this error.
Search User By Email [It]
/Users/toddnine/develop/go/src/github.com/cradlekiwi/api/dataaccess/user_test.go:157
Test Panicked
runtime error: invalid memory address or nil pointer dereference
/usr/local/Cellar/go/1.7.4_2/libexec/src/runtime/panic.go:458
Full Stack Trace
/usr/local/Cellar/go/1.7.4_2/libexec/src/runtime/panic.go:458 +0x243
github.com/cradlekiwi/api/dataaccess_test.(*userAssert).assertSameUser(0x95a380, 0xc420017080, 0x0)
/Users/toddnine/develop/go/src/github.com/cradlekiwi/api/dataaccess/user_test.go:258 +0x19f
What’s odd, is the code in the test from the trace above has an explicit nil check before it’s assertion on actual.ID, which is the line 258 from the trace.
func (u *userAssert) assertSameUser(expected *model.User, actual *model.User) {
Expect(expected).ShouldNot(BeNil())
Expect(actual).ShouldNot(BeNil())
Expect(actual.ID).ShouldNot(BeNil())
}
If I’ve asserted the field “actual” is not nil the line before I check it’s field ID, how can I possibly be getting an invalid memory address or a nil pointer? This error is completely intermittent. I see it in 1 out of around 14 test runs. What’s very odd is I can reproduce it in both a docker container and on my OSX laptop. All envs are go 1.7.4. I’ve noticed this since 1.6, and I’m making it a priority to track it down. Any help would be greatly appreciated!
Thanks,
Todd