Commit Graph

942 Commits (1419-fail-assertions)

Author SHA1 Message Date
Bracken Dawson e2e5626522
Add missing Helper calls to IsIncreasing et al 2024-02-24 14:56:17 +00:00
Bracken 685783ac52
Clarify error message for incorrect use of IsIncreasing et al
Because maps are collections but not ordered.

Co-authored-by: Olivier Mengué <dolmen@cpan.org>
2024-02-24 14:55:03 +00:00
Bracken Dawson 8b4aef060a
IsIncreasing et al can return false w/out failing
If you passed a non-collection to IsIncreasing or any of its compatriots then the assertion would return false without failing the test.
2024-02-24 14:55:03 +00: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
Sean Marciniak c3b0c9b4f5
Merge pull request #1502 from stretchr/suite-fix-reporting-of-panic-location
suite: fix recoverAndFailOnPanic to report test failure at the right location
2024-02-01 08:44:43 +10:30
Olivier Mengué 2be68b5e9e suite: fix recoverAndFailOnPanic to report at the right location
Add calls to t.Helper() to fix the location where the panic is reported
as a test failure.
2024-01-31 16:01:43 +01:00
Olivier Mengué b139300e7e
Merge pull request #1450 from stretchr/CI-go1.21
CI: use 'stable' and 'oldstable' indirections to refers to Go versions
2024-01-31 16:00:29 +01:00
Olivier Mengué c86e139511 CI: add go 1.21 2024-01-31 15:57:41 +01:00
Sean Marciniak 9b9a3b48b1
Merge pull request #1412 from stretchr/fix-flaky-TestEventuallyIssue805
assert: fix TestEventuallyTimeout
2024-01-26 13:58:29 +10:30
Sean Marciniak 0feb1d9baf
Merge branch 'master' into fix-flaky-TestEventuallyIssue805 2024-01-25 09:12:58 +10:30
Sean Marciniak 648a7937c5
Merge pull request #1416 from stretchr/mock-simplify-matcher-check
mock: optimize argument matching checks
2024-01-22 08:48:09 +10:30
Sean Marciniak 24e57f1a77
Merge pull request #1444 from stretchr/mock-refactor-TestIsArgsEqual
mock: refactor TestIsArgsEqual
2024-01-22 08:44:43 +10:30
Sean Marciniak 12f05f76ab
Merge pull request #1453 from stretchr/fix-1292-dep-cycle-with-objx
Fix dependency cycle with objx #1292
2024-01-22 08:44:18 +10:30
Sean Marciniak 14d4b9bcc6
Merge pull request #1483 from stretchr/fix-1231-InEpsilonSlice-expected-actual-order
assert.InEpsilonSlice: fix expected/actual order and other improvements
2024-01-22 08:43:45 +10:30
Sean Marciniak 92533fad9b
Merge pull request #1506 from stretchr/assert-simplify-isNil
assert: simplify isNil implementation
2024-01-22 08:39:01 +10:30
Sean Marciniak 1f53b4e175
Merge pull request #1505 from stretchr/more-unsafe.Pointer-tests
assert: improve unsafe.Pointer tests
2024-01-18 03:08:17 +10:30
Luca Berneking 74a35d55d5 Support Pointer to Struct in EqualExportedValues
This PRs allows to `EqualExportedValues` pointers to structs.
2023-12-08 12:42:36 +01:00
Olivier Mengué cbcc423cdf assert: simplify isNil implementation
Simpler and faster (also less allocations) in internal isNil().
2023-11-09 16:40:41 +01:00
Olivier Mengué 858080fbab assert: more unsafe.Pointer tests
1. Isolate tests that use the "unsafe" package in a separate package
   assert/internal/unsafetests. That way the assert package is not
   tainted with unsafe.
2. Remove one reference to the private assert.isNil() in assert tests.
3. Add more tests of assert.Nil and assert.NotNil with unsafe.Pointer.
2023-11-09 16:32:25 +01:00
Olivier Mengué db8608ed63
suite: fix subtest names (fix #1501) (#1504)
* suite: fix TestSubtestPanic failure (#1501)

The subtest of TestSubtestPanic is expected to fail, but that must not
make the testuite of package 'suite' to fail. So call Skip to make 'go
test' to ignore that expected failure.

* suite: fix subtests names

We are doing dirty things with testing.InternalTest. It looks like test
names should have the same prefix as the parent test, like if they were
true subtests (testing.T.Run).

So until we drop our usage of testing.InternamTest, let's rename the
tests.

Also added a few checks of the testing.RunTests result.
2023-11-09 10:44:27 +10:00
Craig Davison 331c520966 Improve readability 2023-10-31 15:54:18 +01:00