* Added Go 1.18.1 as a build/supported version
Removed Go 1.15.13 as a build version as it's no longer supported
* Fix mutex passed by value for the Mock struct
* Add mutex initialisation for Mock
Co-authored-by: Boyan Soubachov <bsoubachov@atlassian.com>
Like `assert.IsType(...)`, `mock.IsType` is used to check that the
type of an argument is the expected type. This is an alternative
to `AnythingOfType`.
Go tip contains following commmit, that inlines function with single
call bodies.
13baf4b2cd
`(*Call).On()` is the exact target for the improvement in Go repo. Due to
the inlining, assert.CallerInfo() can't not detect the file and line
number of the call to `(*Mock).On()` from `(*Call).On()`. Thus, the test
fails.
Adding the compiler directive `go:noinline` prevent this effect and make
mock package works with go tip as before.
This makes is possible to fail the test instead of panicing in case
that the method was called with unexpected arguments.
Fixes#489
mock: change field 'T' to be private field 'test'
mock_test: MockTestingT not using Mock anymore
commit 5b0291d47dc3a70cc6c6be3bba3c2f934a8e933e
Merge: 1f324ec 8ccf48a
Author: Dinesh Kumar <dineshkumar-cse@users.noreply.github.com>
Date: Sat Dec 30 19:55:13 2017 +0530
Merge branch 'master' into master
commit 1f324ec8cbe892a2c5364904643aa1b710121824
Author: Dinesh Kumar <dinesh.kumar@go-jek.com>
Date: Sat Dec 30 19:07:16 2017 +0530
Fixing comments: reduced test time, locking in after, unexported waitTime
- WaitUntil/After overrides each other value
- currently if channel is set that takes the priority, if not the
waitTime is used to Sleep
commit a7101ec14224918fc06532acae76418d1b4f04c5
Author: Dinesh Kumar <dinesh.kumar@go-jek.com>
Date: Fri Dec 29 13:02:14 2017 +0530
Using if else instead of switch and pulling out the commone one
commit 936f63dd689acacfd051867c5c700489caa1dbc2
Author: Dinesh Kumar <dinesh.kumar@go-jek.com>
Date: Fri Dec 29 12:41:40 2017 +0530
After - making it wait during method call
After was using call.WaitUntil(time.After(duration)),
<-time.After(duration) returns a channel with the timer immediately
started
This change fixes a race condition I discovered when a multithreaded
test in a service I work on failed under -race. The included test case
simulates that failure (concurrent mutation of a Call with invocations
on the mock). The test will fail with a data race if run under the
race detector; the new locking ensures that call fields are not
accessed without the protection of the parent mutex.
When `len(actual) > len(expected)`, this for loop would cause a panic.
Alternative to this implementation, there could be a check for
`if len(actual) != len(expected)`, but generating a meaningful message
describing that is already provided by `diff()`. So we defer to diff in
every case.
Fixes#393