802 Commits

Author SHA1 Message Date
Bracken
cf1284f8dd
Allow mock expectations to be ordered (#1106)
* Allow mock expectations to be ordered

* Only say another call if it has been called before
2022-06-28 22:13:45 +10:00
Oladapo Ajala
66eef0ef3a
fix: assert.MapSubset (or just support maps in assert.Subset) (#1178)
* WIP: added map key value check in subset

* upgraded subset & notsubset to check handle maps
2022-06-28 21:24:53 +10:00
Ruan Moolman
2fab6dffcf
Add WithinTimeRange method (#1188)
* Add WithinTimeRange method

* Run ./.ci.generate.sh

* Rename WithinTimeRange to WithinRange

* Rename WithinRange expected parameter to actual

* Capitalise start parameter at start of error message

* Improve WithinRange example
2022-06-28 21:14:39 +10:00
Edward Raigosa
b5ce165710
fixing panic in calls to assertion with nil m.mutex (#1212)
* fixing panic in calls to assertion with nil m.mutex

This reverts a change that was made in https://github.com/stretchr/testify/pull/1182
The PR makes m.mutex a pointer which now needs to be checked but it's not checked for nil everywhere.

This should also help with these issues:
- https://github.com/stretchr/testify/issues/1208
- https://github.com/stretchr/testify/issues/1210

* Revert throwing out the lock because other concurrent calls can already have it locked

* fix go vet copy lock by using pointer

* fix obj assignment for passing test
v1.7.5
2022-06-24 10:11:59 +10:00
Bracken
c206b2e823
Mock can be deadlocked by a panic (#1157)
If an argumentMatcher function panics and AssertExpectations is deferred then the test would deadlock.
2022-06-23 19:42:21 +10:00
nicoche
1b73601ae8
suite: correctly set stats on test panic (#1195) 2022-06-23 19:40:15 +10:00
Paul Dufour
ba1076d8b3
Add .Unset method to mock (#982)
* Add .Off method to mock

* Update README.md

* Update mock.go

* Update mock_test.go

* Update README.md

* Fix tests

* Add unset test

* remove prints

* fix test

* update readme
2022-06-22 19:31:35 +10:00
Ryan Leung
c31ea0312f
Support comparing byte slice (#1202)
* support comparing byte slice

Signed-off-by: Ryan Leung <rleungx@gmail.com>

* address the comment

Signed-off-by: Ryan Leung <rleungx@gmail.com>
2022-06-21 14:54:58 +10:00
Tony Abboud
48391ba5eb
Fix panic in AssertExpectations for mocks without expectations (#1207)
Co-authored-by: Tony Abboud <tabboud@palantir.com>
v1.7.4
2022-06-21 07:08:00 +10:00
Adam Luzsi
840cb80149
arrays value types in a zero-initialized state are considered empty (#1126)
* fix .Empty assertion with Array types

* refactor .Empty assertion for array types
2022-06-20 20:44:27 +10:00
dependabot[bot]
07dc7ee5ab
Bump actions/setup-go from 3.1.0 to 3.2.0 (#1191)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
v1.7.3
2022-06-20 20:32:41 +10:00
dependabot[bot]
c33fc8d30d
Bump actions/checkout from 2 to 3 (#1163)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-20 20:23:43 +10:00
Boyan Soubachov
3c33e07c4c
Added Go 1.18.1 as a build/supported version (#1182)
* 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>
2022-06-14 20:50:25 +10:00
dependabot[bot]
e2b56b3a38 Bump github.com/stretchr/objx from 0.1.0 to 0.4.0
Bumps [github.com/stretchr/objx](https://github.com/stretchr/objx) from 0.1.0 to 0.4.0.
- [Release notes](https://github.com/stretchr/objx/releases)
- [Commits](https://github.com/stretchr/objx/compare/v0.1.0...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/objx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-14 20:44:02 +10:00
Karol Lassak
41453c009a Update gopkg.in/yaml.v3 v1.7.2 2022-06-06 19:52:45 +10:00
Jeff Widman
285adcc5ce Update go versions in build matrix
These are the latest versions listed on https://go.dev/dl/
2022-05-13 21:12:09 +10:00
dependabot[bot]
6e7fab43fc Bump actions/setup-go from 2 to 3.1.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3.1.0)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-13 21:10:54 +10:00
Weizhen Wang
106ec21d14 use RWMutex
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
2022-05-04 20:46:29 +10:00
Weizhen Wang
a409ccf19e fix data race in the suit
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
2022-05-04 20:46:29 +10:00
cuishuang
35864782d2 assert: fix typo
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-05-04 20:29:57 +10:00
Jeff Widman
7797738693 Update versions supported to include go 1.16
Rather than directly adding `1.16`, I thought better to reword to state the minimum version supported... this way the line doesn't have to get updated with every new release, but instead only when dropping releases.
2022-03-17 22:47:27 +10:00
RmbRT
083ff1c044 Fixed didPanic to now detect panic(nil).
Previously, the function would not detect panic(nil) calls.
In didPanic, removed the anonymous function call, instead,
added named return values. Added extra test cases for the
panic(nil) call.
v1.7.1
2022-03-16 07:08:43 +10:00
Torkel Rogstad
1e36bfe104 Use cross Go version compatible build tag syntax 2022-02-15 20:26:04 +10:00
Torkel Rogstad
e798dc2763 Add docs on 1.17 build tags 2022-02-15 20:26:04 +10:00
Torkel Rogstad
83198c2c50 assert: guard CanConvert call in backward compatible wrapper 2022-02-15 20:26:04 +10:00
Torkel Rogstad
087b655c75 assert: allow comparing time.Time 2022-02-15 20:26:04 +10:00
Ilia Kravets
7bcf74e94f fix msgAndArgs forwarding 2022-02-10 20:09:05 +10:00
Ilia Kravets
c29de71342 add tests for correct msgAndArgs forwarding
len(msgAndArgs)>1 should lead to fmt.Sprintf()
2022-02-10 20:09:05 +10:00
Boyan Soubachov
f87e2b2119 Update builds
* Add Go 1.17.6 to the build versions
* Remove Go 1.14
* Remove unused TravisCI file
2022-02-10 20:07:02 +10:00
Menno
ab6dc32628 fix linting errors in /assert package 2021-08-24 21:55:23 +10:00
Menno
edff5a049b fix funtion name 2021-08-24 21:55:23 +10:00
Menno
5c61ef97ae fix potential nil-pointer dereference
the fix gracefully fails the assertion instead of panicking unresolved.
2021-08-24 21:55:23 +10:00
perrydunn
e209ca88af Improve mock.MatchedBy failed comparison Diff message 2021-08-24 20:26:52 +10:00
Matthieu MOREL
a9de4f065a Create dependabot.yml 2021-07-20 16:55:38 +02:00
Menno
fd9e1fb0e1 Fix NaN similarity checks
Plus minor alignments in code.
2021-07-09 20:35:46 +10:00
Boyan Soubachov
ee42bbe4ab Use multiple run commands 2021-07-08 22:18:43 +10:00
Boyan Soubachov
57bf675175 Update go versions 2021-07-08 22:18:43 +10:00
Boyan Soubachov
6c59e0f73d Convert CI to use GitHub Actions 2021-07-08 22:18:43 +10:00
neilisaac
6241f9ab99 Add String method to Mock to fix #625 2021-04-27 21:38:32 +10:00
Harald Nordgren
dc5c261377 Make sure time.Time comparison produces a helpful diff. closes #989 2021-04-27 21:16:43 +10:00
Alun Evans
6990a05d54 Add ErrorContains 2021-01-16 12:32:05 +11:00
Yongxin Wang
bf646ea5b3 add test to check that Helper is called 2021-01-15 21:06:28 +11:00
Yongxin Wang
6f81fdf1db fix the output source file in test output 2021-01-15 21:06:28 +11:00
Tomáš Procházka
a2f7dbf150 Change Readme to reflect supported Go versions 2021-01-15 21:03:40 +11:00
Bo Sunesen
acba37e5db Only use repeatability if no repeatability left v1.7.0 2021-01-13 20:54:11 +11:00
Bo Sunesen
eb8c41ec07 Add more tests to mock package 2021-01-13 20:54:11 +11:00
Bo Sunesen
a5830c56d3 Extract method to evaluate closest match 2021-01-13 20:54:11 +11:00
Bo Sunesen
1962448488 Use Repeatability as tie-breaker for closest match 2021-01-13 20:54:11 +11:00
Acho Arnold
92707c0b2d Fixed the link to not point to assert only 2020-11-03 21:39:35 +11:00
Acho Arnold
05dd0b2b35 Updated the readme to point to pkg.dev 2020-11-03 21:39:35 +11:00