Commit Graph

850 Commits (fix-1292-dep-cycle-with-objx)

Author SHA1 Message Date
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é 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
Olivier Mengué 486eb6f08c
Merge pull request #1406 from dolmen-go/use-std-header-for-generated-code
codegen: use standard header for generated files
2023-07-22 08:51:09 +02:00
Olivier Mengué af4d8a66cf
Merge pull request #1320 from lesichkovm/patch-1
Fix adding ? when no values passed
2023-07-11 22:52:16 +02:00
Olivier Mengué 78aedbf433
Merge pull request #1409 from SuperQ/test_old_versions
CI: run tests from go1.17
2023-07-06 13:09:59 +02:00
SuperQ 95683d1a6c
Add tests for old Go versions
Test old Go versions all the way back to 1.17.

Signed-off-by: SuperQ <superq@gmail.com>
2023-07-06 12:59:57 +02:00
Olivier Mengué 0a3163c6c4
Merge pull request #1410 from alexandear/docs-fix-typos
doc: Fix typo in godoc

Also fix typos in tests (assertion messages).
2023-07-06 12:33:18 +02:00
Oleksandr Redko 37814a1755 docs: Fix typos in tests and comments 2023-07-06 13:14:39 +03:00
Olivier Mengué 34b86428f4
Merge pull request #1346 from LandonTClipp/mockery_docs
README: update mockery link to point to doc on Github Pages
2023-07-05 12:52:28 +02:00
Olivier Mengué 4f6e609334
Merge branch 'master' into mockery_docs 2023-07-05 12:49:36 +02:00
Olivier Mengué 204612911e
README: fix link to mockery tool 2023-07-05 12:48:13 +02:00
Olivier Mengué 6bfed73816
Merge pull request #1349 from davidjb/patch-1
README: fix URLs to point to go.dev/pkg.go.dev
2023-07-05 12:39:07 +02:00
Olivier Mengué c6ffad3f5c
Merge pull request #1389 from echarrod/master
Correct spelling/grammar in README and comments
2023-07-05 12:18:24 +02:00
Olivier Mengué b247874fc3
Merge pull request #1367 from stretchr/mvdkleijn-patch-1
Remove mvdkleijn from MAINTAINERS.md on his request
2023-07-05 12:01:22 +02:00
Olivier Mengué 945f91b9b9
Merge pull request #1392 from programmer04/improve-docs
Document that require is not safe to call in created goroutines
2023-07-05 11:59:09 +02:00
Olivier Mengué 68bbf7ae46
Merge pull request #1394 from SuperQ/go_min
Set Go version to 1.19 (oldstable) in go.mod
2023-07-05 11:57:03 +02:00
Olivier Mengué 5ca0755b51 codegen: use standard header for generated files
Use the standard header in generated Go sources.
See https://go.dev/s/generatedcode.
2023-07-02 21:06:15 +02:00
SuperQ b5eddf779a
Fix Go modules version
The `go` directive in go.mod is meant to indicate the minimum supported
version.

See: https://go.dev/doc/modules/gomod-ref#go

Signed-off-by: SuperQ <superq@gmail.com>
2023-06-02 16:11:11 +02:00
Jakub Warczarek e18a70d446
Document that require is not safe to call in created goroutines 2023-05-31 11:34:43 +02:00
Martti T f97607b898
Create GitHub release when new release tag is pushed (#1354) 2023-05-30 19:38:40 +10:00
Ed 9f0f17fe64 Correct spelling/grammar 2023-05-26 10:38:59 +01:00
Harald Nordgren 4c93d8f201
EqualExportedValues: Handle nested pointer, slice and map fields (#1379)
* EqualExportedValues: Handle pointer and slice fields

* Update assert/assertions.go

Co-authored-by: Michael Pu <michael.pu123@gmail.com>

* Reduce redundant calls to 'copyExportedFields'

* Update comments

* Add support for maps

* Update Go version support to 1.19 and onward

* Re-generate after rebasing

---------

Co-authored-by: Michael Pu <michael.pu123@gmail.com>
2023-05-11 07:42:04 +10:00
Tobias Krischer 4b2f4d2bcf
add EventuallyWithT assertion (#1264)
* add EventuallyWithT assertion

* Change "EventuallyWithT" condition acceptance to no-errors raised

This change updates the "EventuallyWithT" assertion variants (regular, formatted,
requirement) to consider a condition as "met" if no assertion errors were raised
in a tick.

This allows to write easier conditions which simply contain assertions, without
needing to return a bool. The equivalent of a condition returning true in the
previous implementation would be a a condition with a single "assert.True(..)" call.

* Declare the "Collect.Copy(T)" method as a testing helper

* run go generate

---------

Co-authored-by: Arik Kfir <arik@kfirs.com>
2023-05-10 06:58:49 +10:00
Nisheeth Barthwal b3106d772c
allow testing for functional options (#1023)
* allow testing for functional options

* add linting docs

* use reflect magic to obtain FunctionalOption name

Co-authored-by: dillonstreator <dillonstreator@gmail.com>

---------

Co-authored-by: dillonstreator <dillonstreator@gmail.com>
2023-05-10 06:55:48 +10:00
wwade 437071b948
assert: fix error message formatting for NotContains (#1362)
* assert: rename and refactor TestContainsFailMessage

I've renamed it to TestContainsNotContains and added a test case
structure so that I can use this test to validate the failure messages
from both Contains and NotContains,

There are no functional changes here, strictly refactoring. A new test
case will be added in a subsequent change.

* assert: fix error message formatting for NotContains

It was using "%s" to format the s and contains arguments, but these
could be any type that supports iteration such as a map. In this case
of NotContains failing against a map, it would print something like:

   "map[one:%!s(int=1)]" should not contain "one"

Fix this using "%#v" as was already done for Contains and added test
cases covering both the "len()" / iterable failure messages as well as
the Contains/NotContains failure case.

The new message for this example map would be something like:

    map[string]int{"one":1} should not contain "one"
2023-05-05 14:05:51 +10:00
Martijn 02647d3471
Remove myself from MAINTAINERS.md
As I am supposed to be a maintainer but have almost zero access to actually manage the project, I've found it difficult to help out. Since then my time has become fragmented and as such I'm removing myself as maintainer.
2023-04-07 08:55:49 +02:00
Michael Pu c5fc9d6b6b
Compare public elements of struct (#1309)
* Implement checking only exported fields

Co-authored-by: Anthony Chang <anthony-chang@users.noreply.github.com>

* Update comment

* Run go generate

* Make compatiable with Go 1.16.5

* Fix go generate files

* Fix white space changes

* Fix whitespace changes

* Fix whitespace changes in gogenerate files

---------

Co-authored-by: Anthony Chang <anthony-chang@users.noreply.github.com>
2023-03-14 22:01:35 +10:00
鈴木 光 75b9b6dfff update: log reason output only if failed 2023-03-09 18:49:15 +09:00
David Beitey d099934742 docs: Update URLs in README 2023-03-05 12:32:34 +10:00
Daniel White f36bfe3c33
Fix Subset/NotSubset when map is missing keys from the subset (#1261)
`MapIndex` returns a zero `reflect.Value` if the map value does not
exist. This now aligns more closely with `InDeltaMapValues` by
checking `reflect/Value.IsValid`.

The use of `recover()` was hiding this error by setting the result of
the test to be "false" despite the test suite passing. This led to
flapping tests where they would succeed if the panic occurred on a
missing key before comparing key values that didn't match!

I've ensured the test suite now asserts on the expected error message
and added another example where the subset has keys not found on the
map under test.
2023-02-25 22:46:30 +10:00
Landon Clipp 0291ba6dc2
https 2023-02-11 01:59:47 -06:00
LandonTClipp d2db48976a Update mockery link to Github Pages 2023-02-11 01:23:36 -06:00
Artem V. Navrotskiy 0ab3ce1249
Fix `CallerInfo()` source file paths (#1288) 2023-01-03 20:57:11 +10:00
lisitsky 2b00d33aec
Fix Call.Unset() panic (issue #1236) (#1250)
Unset changes len of a `ExpectedCalls` slice during iteration while using index from original slice, and under some conditions it tries to reslice element beyond of the slice boundaries. That causes panic.

The proposed solution uses independent write index to count elements kept in output slice.

Tests (the simplest and more complicated cases) and comments are included.
2023-01-03 20:44:42 +10:00
Milan Lesichkov c029f419b8
Fix adding ? when no values passed 2022-12-22 10:45:24 +00:00
sunpeng 9acc22213e
fix: fix bug for check unsafe.Pointer isNil (#1319) 2022-12-20 19:39:16 +10:00
Vadym Tishchenko 1333b5d3bd
Add sub-tests to Suite (#1246)
Co-authored-by: Vadym Tishchenko <v.tishchenko@evopay.com.ua>
2022-11-02 21:46:59 +10:00
dependabot[bot] b747d7c5f8
Bump github.com/stretchr/objx from 0.4.0 to 0.5.0 (#1283)
Bumps [github.com/stretchr/objx](https://github.com/stretchr/objx) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/stretchr/objx/releases)
- [Commits](https://github.com/stretchr/objx/compare/v0.4.0...v0.5.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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-20 20:50:56 +10:00
Stavros Ntentos 181cea6eab
impr: `CallerInfo` should print full paths to the terminal (#1201)
* impr: `CallerInfo` should print full paths to the terminal

I am proposing this simple change, which changes this output
```
--- FAIL: TestABC (0.00s)
    --- FAIL: TestABC/C (0.00s)
        /this/is/a/path/to/file_test.go:258:
            	Error Trace:	file_test.go:258
            	            				file_test.go:748
            	Error:      	Not equal:
...
```
to this:
```
--- FAIL: TestABC (0.00s)
    --- FAIL: TestABC/C (0.00s)
        /this/is/a/path/to/file_test.go:258:
            	Error Trace:	/this/is/a/path/to/file_test.go:258
            	            				/this/is/a/path/to/file_test.go:748
            	Error:      	Not equal:
...
```

With the latter output, it is much more straightforward to find the file
you are looking for, even though in the displayed case, the file is the same.

However, for VSCodium, the case is a little more helpful, since VSCodium's
terminal is smart enough to recognize the output, and make links out of that input.

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>

* test: fix the tests that depended on the previous behavior

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>

Co-authored-by: Stavros Ntentos <11300730-stavros-relex@users.noreply.gitlab.com>
2022-06-29 20:56:06 +10:00
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