1091 Commits

Author SHA1 Message Date
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
Ian Rose
1837f62a5f Ensure AssertExpectations does not fail in skipped tests 2023-10-31 00:00:55 +01:00
Olivier Mengué
21ba5d23bb
Merge branch 'master' into uintptr 2023-10-30 23:51:22 +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é
f19cdfc9fe
Merge branch 'master' into patch-1 2023-10-16 19:23:14 +02:00
Herman Slatman
4e56e1ee06 Add NotImplements and variants 2023-10-16 14:27:51 +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
Olivier Mengué
975128c5e6 deps: upgrade objx to v0.5.1 to fix dep cycle
See https://github.com/stretchr/objx/pull/140

go get github.com/stretchr/objx@v0.5.1
2023-08-09 16:18:00 +02:00
Olivier Mengué
882382d845
Merge pull request #1441 from stretchr/mock-deprecate-AnythingOfTypeArgument
mock: deprecate AnythingOfTypeArgument (#1434)
2023-08-08 11:46:46 +02:00
Olivier Mengué
f24f3ba986 mock: deprecate AnythingOfTypeArgument (#1434)
Deprecate mock.AnythingOfTypeArgument which should never have been
publicly exposed.

AnythingOfTypeArgument is now a type alias to the private
anythingOfTypeArgument and is marked as Deprecated in godoc.
The AnythingOfType constructor is still available.

The aim is to completely remove that alias.
2023-08-08 11:05:09 +02:00
Olivier Mengué
0e90845e22
Merge pull request #1445 from stretchr/assert-refactor-getLen
assert: refactor internal func getLen()
2023-08-08 11:04:26 +02:00
Olivier Mengué
9e58631a03 assert: reverse return values of internal getLen()
Reverse order of return values of internal function getLen() to be more
consistent with stdlib (ex: os.LookupEnv).

Old: func (any) (ok bool, length int)
New: func (any) (length int, ok bool)
2023-08-08 11:01:35 +02:00
Olivier Mengué
7a796b8f87 assert: simplify getLen() implementation 2023-08-08 11:01:35 +02:00
Anant Vyas
a23f5db224
mock: move regexp compilation outside of Called (#631)
Co-authored-by: Olivier Mengué <dolmen@cpan.org>
2023-08-01 10:07:29 +02:00
Ivan Pesenti
a392378178 Fixed typos
"Setup" means an existing arrangeament while "set up" is an action.
2023-07-31 19:15:21 +02:00
Olivier Mengué
81667ad920 assert: fix flaky TestNeverTrue
Fix flaky TestNeverTrue: use a channel to make a synchronized list of
return values to avoid a race condition.
2023-07-31 19:06:57 +02:00
Olivier Mengué
c740480fc1 mock: refactor TestIsArgsEqual
Refactor tests to use 'append' to build copies of slices instead of
manual loops.

Thanks golangci-lint.
2023-07-30 20:51:12 +02:00
Olivier Mengué
862e41010c
Merge pull request #1360 from hikyaru-suzuki/feature/update_logging_output
mock: AssertExpectations log reason only on failure
2023-07-29 05:52:15 +02:00