900 Commits

Author SHA1 Message Date
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
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
Craig Davison
5f48c62606 address some review comments 2023-10-31 15:54:18 +01:00
Craig Davison
b7c378d6bd captureTestingT.checkResultAndErrMsg 2023-10-31 15:54:18 +01:00
Craig Davison
002647e9f8 TestErrorIs/TestNotErrorIs: check error contents 2023-10-31 15:54:18 +01:00
Justin Chadwell
5105b61304 Add map support doc comments to Subset and NotSubset
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-31 00:24:17 +01:00
Oleksandr Redko
43b2ef12b3 Change to use godoc 2023-10-31 00:07:12 +01:00
Oleksandr Redko
056e9e6bfa docs: Fix deprecation formatting for http 2023-10-31 00:07:12 +01:00
Linus Barth
7df1a82a31 test: add suite tests for panicking of subtests 2023-10-30 22:51:08 +01:00
Linus Barth
a4a54a4597 fix: panic behavior for subtests
This fix adds panic handling for subtests which will achieve:
- subtests will fail for the correct test context when panicking
- the test execution is not stopped; the next subtest will be executed
2023-10-30 22:51:08 +01:00
Linus Barth
65318c364a improve: tests for asserting test names in subtests 2023-10-30 22:51:08 +01:00
Linus Barth
130d340262 improve: move comment to msgAndArgs-param in test 2023-10-30 22:51:08 +01:00
Linus Barth
855d1c6784 test: testing.T correctness in subtests setup/teardown 2023-10-30 22:51:08 +01:00
Linus Barth
82022eeb0d test: call order of setup/teardown for subtests 2023-10-30 22:51:08 +01:00
Linus Barth
4526456fa4 improve: defer-style in Suite.Run() 2023-10-30 22:51:08 +01:00
Linus Barth
737a765d89 fix: SetupSubTest and TearDownSubTest execution order
There were two problems with the order of execution in the Suite.Run() method:
- One could not access the correct testing context ("s.T()") inside the SetupSubTest and TearDownSubTest methods. If the testing context was used for e.g. assertions of mocks in the TearDownSubTest, the results would not be "attached" to the correct test in the test output.
- The behavior was different to the order of execution for "root" tests (see lines 167-201) regarding the SetupTest and TearDownTest methods. This could confuse users of the library.

Also the logic to be deferred was joined together. This was fine beforehand because a panic in the TearDownSubTest would have had no influence on the "suite.SetT(oldT)". Now since a panic in the TearDownSubTest would lead to omitting the "suite.SetT(oldT)" this defer was split into two separate defers.
2023-10-30 22:51:08 +01:00
Oleksandr Redko
351d2776c6 Revert some changes 2023-10-30 22:41:11 +01:00
Oleksandr Redko
375474cd3c suite: refactor test assertions 2023-10-30 22:41:11 +01:00
Harald Nordgren
fc1dee9921 Deprecate EqualExportedValues 2023-10-24 09:21:34 +02:00
Kevin Burke
7f962d56e4 .github: use latest Go versions
Also update the runners to their latest versions.
2023-10-24 09:10:36 +02:00
Olivier Mengué
f8dcfd6618 assert.InEpsilonSlice: mention index of error in fail message 2023-10-18 18:46:08 +02:00
Olivier Mengué
7d383ba732 assert.InEpsilonSlice: refactor 2023-10-18 18:46:08 +02:00
Olivier Mengué
f7fbc7da15 assert.InEpsilonSlice: fix order of expected vs actual (#1231) 2023-10-18 18:46:08 +02:00
Olivier Mengué
8fd5aae061 assert.InEpsilonSlice: remove redundant check
Remove check of actual's kind redundant with Type()'s check.
2023-10-18 18:46:08 +02:00
Olivier Mengué
f728d3c50f assert.InEpsilonSlice: refactor
Remove multiple calls to reflect.Value.Len()
2023-10-18 18:46:08 +02:00
Olivier Mengué
b5dec80529 assert.InEpsilonSlice: add more slice checks 2023-10-18 18:46:08 +02:00
Olivier Mengué
ab3b9743a7 assert.InEpsilonSlice: refactor 2023-10-18 18:46:08 +02:00
Olivier Mengué
5dca985ff4 assert: remove logs in TestEventuallyTimeout 2023-10-16 21:14:11 +02:00
Olivier Mengué
e8837d5396 assert: fix TestEventuallyTimeout
Fix TestEventuallyIssue805 which was flaky because of the use of a timer
that has exactly the same duration as the Eventually timout. But time is
not a synchronization primitive.

Now we use channels to ensure that the condition is still running and
Eventually times out before checking its return value.

The test is also renamed to TestEventuallyTimeout to more clearly show
its purpose.
2023-10-16 21:12:04 +02:00
Olivier Mengué
307c9344b8 mock: refactor IsType
Reduce calls to reflect.Type in implementation of mock.IsType by
extracting the type early.

This also avoids to keep alive references to the argument value.
2023-10-16 13:57:23 +02:00
Olivier Mengué
413628c0f4 mock: simplify Arguments.Diff
Use a type switch instead of reflect.TypeOf comparisons.
2023-10-16 13:57:23 +02:00
Zachary Becker
4ae48e988c Combine switch cases, difference wrapped in if statement 2023-10-16 00:55:57 +02:00
Zachary Becker
2f7efa2451 Fix bug where array is treated as slice in EqualExportedValues 2023-10-16 00:55:57 +02:00
hidu
ce5c2b684b assert: fix httpCode and HTTPBody occur panic when http.Handler read body 2023-10-15 23:34:32 +02:00
Grzegorz Burzyński
89920137cd collect errors from condition in defer 2023-10-13 08:53:17 +02:00
Grzegorz Burzyński
4ed68e1bca fix: make EventuallyWithT concurrency safe 2023-10-13 08:53:17 +02:00
dependabot[bot]
11a6452626 Bump actions/setup-go from 3.2.0 to 4.1.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.2.0 to 4.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3.2.0...v4.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>
2023-10-10 17:30:50 +02:00
dependabot[bot]
c1ca192909 Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [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/v3...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 17:25:08 +02:00
tscales
34763e0df3 assert: ObjectsAreEqual: use time.Equal for time.Time type 2023-10-10 17:14:01 +02:00
Oleksandr Redko
1ee798c140 Remove canConvert because Go 1.16 is dropped from support 2023-10-10 14:28:34 +02:00
Olivier Mengué
838caeaac1 deps: exclude old testify to break the dependency cycle from objx
In go.mod exclude the old version of testify brought by objx. This
allows to break the dependency cycle and completely remove the
dependency link to old versions of dependencies (some of which had
security issues).

Closes #1292.

go mod edit -exclude=github.com/stretchr/testify@v1.8.2 && go.mod
2023-08-09 16:24:51 +02:00