Commit Graph

962 Commits (assert-deprecate-CompareType)

Author SHA1 Message Date
Olivier Mengué a155d2a49d assert: restore CompareType, but mark it as deprecated
Reinstate CompareType for full backward compatibility, but mark it as
deprecated.
2024-03-20 00:47:39 +01:00
Olivier Mengué 39442a4e4e assert: drop CompareType
Rename CompareType to compareResult to make it private. This type is
used only in internal functions and is of no use for external users and
should never have been made public.

CompareType has been introduced by 0b4ff03cda
and appeared in releases since v1.6.0.

Note: strictly speaking, this is a breaking change, but no external user
should have ever used assert.CompareType as it made no sense in the assert
API. A search on GitHub has revealed no use of it.
https://github.com/search?q=assert.CompareType+language%3AGo&type=Repositories&ref=advsearch&l=Go&l=
2024-03-20 00:47:39 +01:00
Olivier Mengué 74e1cbebab assert: minor refactor of compareTwoValues tests
Refactor compareTwoValues tests to free the 'compareResult' symbol name
(for incoming use of this name in next commit).
2024-03-20 00:47:39 +01:00
Olivier Mengué a71299064b assert: refactor Test_compareTwoValuesCorrectCompareResult
Refactor Test_compareTwoValuesCorrectCompareResult table test to be more
explicit: "compareTypes" renamed to "allowedResults".
2024-03-20 00:47:39 +01:00
Olivier Mengué 3c302f75ae
mock: improve doc (#1570)
## Summary
Improve API doc of package
[`mock`](https://pkg.go.dev/github.com/stretchr/testify/mock):
- add godoc links
- indent example code

## Motivation
Readability.
2024-03-10 11:42:04 +01:00
Olivier Mengué 632a26080f
Merge pull request #820 from TomWright/master
Do not get argument again unnecessarily in Arguments.Error()
2024-03-06 03:05:06 +01:00
Tom Wright cab2acc70f Do not get argument again unnecessarily in Arguments.Error() 2024-03-06 03:03:10 +01:00
Olivier Mengué edb801534f
Merge pull request #1565 from stretchr/gitignore-test-binaries
.gitignore: ignore "go test -c" binaries
2024-03-05 12:09:22 +01:00
Olivier Mengué 89ffab03a5
Merge pull request #1562 from stretchr/make-tHelper-a-type-alias
assert: make tHelper a type alias
2024-03-05 10:48:10 +01:00
Fahim Bagar 8585d8de96
Add PanicAssertionFunc (#1337, #730)
Add a `PanicAssertionFunc` to ease writing table-driven tests for panic
assertion.

Closes #730
2024-03-05 10:13:30 +01:00
Olivier Mengué e5e71998af gitignore: ignore "go test -c" binaries
Ignore binaries produced by "go test -c".
2024-03-04 22:37:21 +01:00
Olivier Mengué 85fabe7c5c assert: make tHelper a type alias
The tHelper interface is defined only for internal usage. We don't need
a "hard" type for it as we don't define methods on it. Let's make is
just a alias to the anonymous interface it represents.

Note: we are already using type aliases elswhere, and type aliases were
introduced a long time ago in Go 1.9.
2024-03-03 18:29:24 +01:00
Bracken bb548d0473
Merge pull request #1552 from stretchr/dependabot/go_modules/github.com/stretchr/objx-0.5.2
build(deps): bump github.com/stretchr/objx from 0.5.1 to 0.5.2
2024-02-29 14:36:18 +00:00
dependabot[bot] 814075f391
build(deps): bump github.com/stretchr/objx from 0.5.1 to 0.5.2
Bumps [github.com/stretchr/objx](https://github.com/stretchr/objx) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/stretchr/objx/releases)
- [Commits](https://github.com/stretchr/objx/compare/v0.5.1...v0.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 11:18:15 +00:00
Bracken e045612245
Merge pull request #1339 from bogdandrutu/uintptr
Add support to compare uintptr
2024-02-28 16:20:56 +00:00
Bracken 5b6926d686
Merge pull request #1385 from hslatman/not-implements
Add `NotImplements` and variants
2024-02-28 16:02:08 +00:00
Bracken 9f97d67703
Merge pull request #1550 from stretchr/release-notes
Include the auto-release notes in releases
2024-02-28 09:53:47 +00:00
Bracken Dawson bcb0d3fe49
Include the auto-release notes in releases 2024-02-27 16:35:20 +00:00
Bracken fb770f8238
Merge pull request #1247 from ccoVeille/typos
fix typos in comments and tests
2024-02-25 11:59:52 +00:00
ccoVeille 85d8bb6eea
fix typos in comments, tests and github templates 2024-02-24 23:48:24 +01:00
Bracken e2741fa4e9
Merge pull request #1548 from arjunmahishi/msgAndArgs
http_assertions: honour the msgAndArgs provided with each assertion
2024-02-23 17:40:20 +00:00
Arjun Mahishi 6e59f20c0d http_assertions: assert that the msgAndArgs actually works in tests
This commit also adds the method `Failed() bool` to the mockTestingT
struct. This is usefull for asserting failure in tests
2024-02-23 22:41:24 +05:30
Arjun Mahishi 840f800f1a http_assertions: Include msgAndArgs is some of the existing tests
A mix of using and not using msgAndArgs will ensure that there is no
regression.
2024-02-23 21:20:50 +05:30
Bracken e65c014fc9
Merge pull request #1248 from guettli/patch-1
README: drop link to gorc
2024-02-23 12:59:46 +00:00
Arjun Mahishi 135b468c5a assert: honour the msgAndArgs provided in InEpsilon 2024-02-23 00:23:39 +05:30
Arjun Mahishi ecdde720b4 http_assertions: honour the msgAndArgs provided with each assertion 2024-02-23 00:16:29 +05:30
Bracken 9f0ad86b78
Merge pull request #1517 from Lucaber/equalExportedValues-ptr
Support Pointer to Struct in EqualExportedValues
2024-02-22 17:16:44 +00:00
Bracken 7c847e2503
Merge pull request #1545 from hendrywiranto/update-setupgo-v5
Update Github workflows setup-go to V5
2024-02-21 23:13:52 +00:00
hendry.wiranto 898b77d0bb try to update to v5 2024-02-21 22:31:33 +07:00
Bracken 7caada5a3b
Merge pull request #1540 from stretchr/build-badge
Update the build status badge
2024-02-20 16:23:09 +00:00
Bracken Dawson e099480d59
Update the build status badge 2024-02-20 12:36:59 +00:00
Bracken 4b9af26649
Merge pull request #1538 from stretchr/issue-templates
[chore] Add issue templates
2024-02-20 10:18:57 +00:00
Arjun Mahishi a5087d7793 [chore] Issue templates: Add link to the discussion page 2024-02-20 11:20:33 +05:30
Arjun Mahishi bd22f81c8f [chore] Issue templates: Switch from bold to H2 headings 2024-02-19 22:53:39 +05:30
Arjun Mahishi 28efcd1170 [chore] Fix typos and improve hints in the issue templates 2024-02-19 22:49:15 +05:30
Bracken fef12e7dc3
Merge pull request #1537 from stretchr/fix-time-equal
Revert "assert: ObjectsAreEqual: use time.Equal for time.Time type"
2024-02-19 12:42:59 +00:00
Arjun Mahishi 5ed61202ae
[chore] Add issue templates 2024-02-19 10:33:44 +05:30
Bracken Dawson 7b3de08425
Revert "assert: ObjectsAreEqual: use time.Equal for time.Time type"
This reverts commit 34763e0df3.

time.Time.Equal only tests that the two instances refer to the same instant, but time.Time also carries zone information, so this caused two non-equal instances to be considered equal.
2024-02-18 20:43:45 +00:00
Bracken 14ffa908e6
Merge pull request #1535 from arjunmahishi/fix-suit-deadlock
suite: fix deadlock in suite.Require()/Assert()
2024-02-18 18:34:49 +00:00
Arjun Mahishi c41592ba5f suite: fix deadlock in suite.Require()/Assert()
As pointed out in issue #1520, if the suite is not initialised properly
(buy calling the Run function), then calling suite.Require() or
suite.Assert() will result in a deadlock.

This commit fixes that by panicking if the suite is not initialised
properly. This is justified because, the suite is intended to be
triggered in the right way. If the user does not do that, this panic will
nudge them in the right direction.

It has to be a panic because, at this point, we don't have access to any
testing.T context to gracefully call a t.Fail(). Also, these two
functions are not expected to return an error.

Fixes #1520
2024-02-18 23:55:01 +05:30
Bracken c719de3088
Merge pull request #1331 from ianrose14/ianrose/assertexpectations-skipped
Ensure AssertExpectations does not fail in skipped tests
2024-02-17 17:50:13 +00:00
Bracken 0e75f9941b
Merge pull request #1485 from kevinburkesegment/len-format
assert: better formatting for Len() error
2024-02-16 15:58:11 +00:00
Kevin Burke 89c0872acd
try to do the whole format string 2024-02-15 11:35:07 -07:00
Kevin Burke f6ed021e60
assert: shorten cases 2024-02-15 11:35:07 -07:00
Kevin Burke f7fedd9f85
assert: better formatting for Len() error
Previously, the use of %s with array objects meant you would get an
error like this:

    "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3

Use %v instead, which provides a much nicer error.

    "[1 2 3]" should have 4 item(s), but has 3

Fixes #1482.
2024-02-15 11:35:07 -07:00
Bracken 5911e38e09
Merge pull request #1531 from arjunmahishi/fix-equal-values
assert: Fix EqualValues to handle overflow/underflow
2024-02-14 15:22:36 +00:00
Arjun Mahishi 4c4d0118a6 assert: Fix EqualValues to handle overflow/underflow
The underlying function ObjectsAreEqualValues did not handle
overflow/underflow of values while converting one type to another
for comparison. For example:

    EqualValues(t, int(270), int8(14))

would return true, even though the values are not equal. Because, when
you convert int(270) to int8, it overflows and becomes 14 (270 % 256 = 14)

This commit fixes that by making sure that the conversion always happens
from the smaller type to the larger type, and then comparing the values.
Additionally, this commit also seperates out the test cases of
ObjectsAreEqualValues from TestObjectsAreEqual.

Fixes #1462
2024-02-14 18:12:21 +05:30
Bracken d25ac14e7d
Merge pull request #1533 from brackendawson/maintainers
Update maintainers
2024-02-14 11:07:13 +00:00
Bracken Dawson d3b6816104
Add emeritus I missed 2024-02-13 23:35:29 +00:00
Bracken Dawson a67cee3a98
Update maintainers
I think I've captured the current list of active committers.
2024-02-13 17:02:43 +00:00