1134 Commits

Author SHA1 Message Date
Olivier Mengué
af716f8bff CI: fix shebang in .ci.*.sh scripts
Fix shebang in .ci.*.sh scripts to ease running on platforms where bash
is not in /bin/bash (ex: MacOS).
2025-05-22 11:53:03 +02:00
Bart Venter
9fc264e324
assert: add IsNotType (#1730)
Add the `IsNotType` assertion, which is the inverse
of the existing `IsType` assertion. It allows users to assert that an
object is not of a specific type.

Additionally, minor documentation improvements were made.

## Summary
This PR adds a new assertion function, `IsNotType`, to the
`testify/assert` package. It complements the existing `IsType` function
by providing a way to assert that an object is not of a specific type.

## Changes
* Added the `IsNotType` function to the `assert` package.
* Wrote unit tests for `IsNotType` to ensure correctness.
* Updated documentation to include examples and usage for `IsNotType`.

## Motivation
The `testify/assert` package already provides an `IsType` function to
check if an object is of a specific type. However, there was no built-in
way to assert that an object is **not** of a specific type. This PR
addresses that gap by introducing the `IsNotType` function, improving
the library's completeness and usability.

## Example usage
```go
assert.IsNotType(t, &MyStruct{}, actualObject)
```

## Related issues
_N/A_
2025-05-22 11:45:11 +02:00
Olivier Mengué
2035e7d7a7
Merge pull request #1739 from ccoveille-forks/asserter-gofumpt
Format assertions files with gofumpt
2025-05-22 10:38:23 +02:00
ccoVeille
9bcca2f950
Format assertions files with gofumpt 2025-05-13 14:17:27 +02:00
Bracken
016e2e9c26
Merge pull request #1671 from alexandear-org/chore/remove-deprecated-build-constraints
assert: remove deprecated build constraints
2025-05-12 15:34:44 +01:00
Bracken
296df14257
Merge pull request #1734 from stretchr/errors-asserter
Improve ErrorAs failure message when error is nil
2025-05-12 15:30:04 +01:00
ccoVeille
c2116b4194
Improve ErrorAs failure message when error is nil
Before:

    Should be in error chain:
    expected: *assert.customError
    in chain:

After:
    An error is expected but got nil.
    expected: *assert.customError

The message `An error is expected but got nil.` is the one already
reported by `assert.Error`
2025-05-08 20:48:57 +02:00
Bracken
111716d6f9
Merge pull request #1729 from siliconbrain/fix-subset-notsubset-mixed-type
fix Subset/NotSubset when calling with mixed input types
2025-05-08 13:42:27 +01:00
Dudás Ádám
121ddb9b0e clarify behavior of Subset/NotSubset when passing maps 2025-05-08 11:16:40 +00:00
Bracken
d338e951cf
Merge pull request #1681 from tsioftas/tsioftas/erroris-improve
Improve ErrorIs message when error is nil but an error was expected
2025-05-08 11:40:41 +01:00
Bracken
520d02e627
Merge pull request #1675 from architagr/doc-update-for-error-fn
Update documentation for the Error function in assert or require package
2025-05-07 13:56:33 +01:00
Archit Agarwal
01b9a87c30
Merge branch 'master' into doc-update-for-error-fn 2025-05-07 17:26:11 +05:30
Archit Agarwal
d0c350a872
Update assert/doc.go
Co-authored-by: Bracken <abdawson@gmail.com>
2025-05-07 17:25:57 +05:30
Bracken
f4244f1680
Merge pull request #1427 from cszczepaniak/cs/quicker_eventually
assert: check early in Eventually, EventuallyWithT, and Never
2025-05-06 14:28:41 +01:00
Bracken
a31a53e5b4
Merge pull request #1615 from DevotedHealth/mauclair-mock-match-sprintf
Lazily render mock diff output on successful match
2025-05-06 11:20:15 +01:00
Archit Agarwal
0c9a9e02f8
Update assert/doc.go
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
2025-05-02 13:01:29 +05:30
Archit Agarwal
992db2b883 upadte doc 2025-04-29 17:10:00 +05:30
Archit Agarwal
e32ceae4ea
Update assert/doc.go
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
2025-04-29 17:08:34 +05:30
Dudás Ádám
2a9c44b1d8 fix Subset/NotSubset when calling with mixed input types (array/slice list with map subset) 2025-04-23 14:31:40 +00:00
Archit Agarwal
d5cd75acec update documentation of assert package to mention that all function return a bool value 2025-04-22 23:33:01 +05:30
tsioftas
e7b1880349 update error message based on suggestion 2025-04-03 14:20:14 +03:00
tsioftas
5ed1b90367
Update assert/assertions_test.go
Co-authored-by: Bracken <abdawson@gmail.com>
2025-04-03 14:17:58 +03:00
Oleksandr Redko
0b6039ed54 assert: remove deprecated build constraints 2025-04-02 12:37:14 +03:00
Archit Agarwal
500cb17e16
Merge branch 'master' into doc-update-for-error-fn 2025-03-26 00:05:52 +05:30
Mike Auclair
e6575e05ed
Update mock.go 2025-03-24 14:24:41 -04:00
Bracken
5ac6528bff
Merge pull request #1716 from brackendawson/update-maintainers
Propose Christophe Colombier (ccoVeille) as approver
2025-03-24 18:30:37 +01:00
Bracken Dawson
d0e0f4961b
Propose Christophe Colombier (ccoVeille) as approver 2025-03-23 18:36:20 +01:00
Bracken Dawson
b561f16e87
Correct maintainers list
arjunmahishi is actually only an approver, at the moment.
2025-03-23 18:33:47 +01:00
Bracken
a948a8c402
Merge pull request #1674 from alexandear/refactor/simplify-with-sprintf-q
refactor: use %q and %T to simplify fmt.Sprintf
2025-03-23 14:23:15 +01:00
Bracken
c3915e850a
Merge branch 'master' into refactor/simplify-with-sprintf-q 2025-03-23 14:22:18 +01:00
Bracken
16020e8cbc
Merge pull request #1687 from alexandear/docs-format-go-examples
README: apply gofmt to examples
2025-03-23 12:09:57 +01:00
Oleksandr Redko
75df9d50d4 Update mdsf 2025-03-23 12:40:01 +02:00
Oleksandr Redko
33be8f984a Move to jobs.build 2025-03-23 12:20:44 +02:00
Oleksandr Redko
a9e8aed155 Remove mistakenly added .ci.gofmt.sh 2025-03-23 12:18:52 +02:00
Bracken
3b8bd9bf7d
Merge pull request #1614 from DevotedHealth/mauclair-call-stack-perf
Call stack perf change for CallerInfo
2025-03-22 23:13:13 +01:00
Bracken
1e7fb5865a
Merge pull request #1709 from techfg/chore/issue-1621-update-docs
chore: update docs for Unset #1621
2025-03-22 12:44:25 +01:00
techfg
c6ac9bb91d chore: update per PR feedback 2025-03-21 06:25:01 -07:00
Bracken
65f73866c0
Merge pull request #1710 from greg0ire/doc-goroutine-restriction
Document consequences of calling t.FailNow()
2025-03-21 13:27:31 +01:00
Grégoire Paris
b1c9368f81
Improve existing docs 2025-03-21 13:21:25 +01:00
Bracken
5a5ac85551
Merge pull request #1062 from lambdanis/fix-fail-message-formatting
Fix failure message formatting for Positive and Negative asserts
2025-03-21 10:15:07 +01:00
Bracken
53e0c918d4
Merge branch 'master' into fix-fail-message-formatting 2025-03-21 10:10:08 +01:00
Grégoire Paris
89086b0757
Document consequences of calling t.FailNow()
These comments are adapted from t.FailNow()'s own documentation.

Closes #1701
2025-03-19 20:50:44 +01:00
techfg
098128fd10 chore: update docs for Unset #1621 2025-03-18 12:48:09 -07:00
Bracken
f784abc221
Merge pull request #1345 from craig65535/fix-assert-erroras
assert.ErrorAs: log target type
2025-03-18 18:04:00 +00:00
Oleksandr Redko
dfda68b86f Verify formatting of code snippets in CI 2025-01-20 19:49:35 +02:00
Oleksandr Redko
3cf0926564 docs: Format examples in README 2025-01-07 11:35:15 +01:00
Craig Davison
c60c3bd7fb dereference target 2025-01-03 14:34:16 -07:00
Archit Agarwal
0c935ad39e
Merge branch 'master' into doc-update-for-error-fn 2025-01-03 21:59:11 +05:30
Craig Davison
1c717c00c1 Add return 2024-12-31 15:35:31 -07:00
Craig Davison
ccb5e7f656 Remove redundant returns 2024-12-31 15:26:24 -07:00