golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.28k stars 610 forks source link

time.Time type value passed to Call.Return differs from value returned #579

Closed steven-eckhoff closed 3 years ago

steven-eckhoff commented 3 years ago

time.Time type value passed to Call.Return differs from value returned by the mocked interface.

I would expect the time.Time value passed to Call.Return to match exactly to the value returned by the mocked interface.

To Reproduce Steps to reproduce the behavior

  1. run mockgen on source file
  2. write test and do something like
    transactionDate := time.Now()
    fmt.Printf("Value passed to Call.Return(): %#v\n", transactionDate)
    deps.clock.EXPECT().Now().Return(transactionDate)
  3. Then on the next EXPECT call use the same transactionDate
  4. set up test with new controller and mocked interface and run
  5. Get an Unexpected call to error with the following
    Got: {0 9.99 3 11 credit 2 3735928559 2999-01-02 00:00:00 +0000 UTC bob goto eleven 42 2021-07-05 15:19:49.711001449 -0500 CDT m=+0.013888202} (SomeType)
        Want: is equal to {0 9.99 3 11 credit 2 3735928559 2999-01-02 00:00:00 +0000 UTC bob goto eleven 42 2021-07-05 15:19:49.710931843 -0500 CDT m=+0.013818600} (SomeType)

Also when I put in some prints I get this

Value passed to Call.Return(): time.Time{wall:0xc030f8396a5ff583, ext:13818600, loc:(*time.Location)(0x1b0fc20)}
Value returned from mocked interface: time.Time{wall:0xc030f8396a610569, ext:13888202, loc:(*time.Location)(0x1b0fc20)}

Additional Information

Triage Notes for the Maintainers