Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: testify.PanicsWithErrorRegex #1304

Open
stdedos opened this issue Nov 18, 2022 · 1 comment
Open

Proposal: testify.PanicsWithErrorRegex #1304

stdedos opened this issue Nov 18, 2022 · 1 comment
Labels
enhancement pkg-assert Change related to package testify/assert

Comments

@stdedos
Copy link
Contributor

stdedos commented Nov 18, 2022

Somewhat-related to #323, I'd like to be able to specify a regex (or a anonymous function callback) to verify "conformance" of the expected panic.

Differently to the issue above, I cannot work with the error outside require.Panics, since Testify swallows it.

@dolmen
Copy link
Collaborator

dolmen commented Jul 25, 2023

assert.Panics definitely lacks flexibility in matching the recovered value as PanicTestFunc doesn't receives it. Bad API design 😕

@dolmen dolmen added enhancement pkg-assert Change related to package testify/assert labels Jul 25, 2023
mvo5 added a commit to mvo5/images that referenced this issue Nov 29, 2023
When trying to create enough data for a full pipeline run for
osbuild#287 I struggled a bit
because it was not clear which items where faulty.

This commit adds more context to the errors. Sadly I had to
implement `assertPanicsWithErrorRegexp` because of
stretchr/testify#1304

I can contribute it upstream but for that it needs some tests
around it first :)
mvo5 added a commit to mvo5/images that referenced this issue Nov 29, 2023
When trying to create enough data for a full pipeline run for
osbuild#287 I struggled a bit
because it was not clear which items where faulty.

This commit adds more context to the errors. Sadly I had to
implement `assertPanicsWithErrorRegexp` because of
stretchr/testify#1304

I can contribute it upstream but for that it needs some tests
around it first :)
mvo5 added a commit to mvo5/images that referenced this issue Nov 29, 2023
When trying to create enough data for a full pipeline run for
osbuild#287 I struggled a bit
because it was not clear which items where faulty.

This commit adds more context to the errors. Sadly I had to
implement `assertPanicsWithErrorRegexp` because of
stretchr/testify#1304

I can contribute it upstream but for that it needs some tests
around it first :)
mvo5 added a commit to mvo5/images that referenced this issue Dec 4, 2023
This adds a new internal package with `testify/assert` extensions.
It contains the new 'PanicsWithErrorRegexp()` helper that can
be removed once upstream stretchr/testify#1304
is fixed (or we contributed this back).

It could not be added to `internal/test` as it would have created
cyclic dependencies when importing from `pkg/osbuild`.
mvo5 added a commit to mvo5/images that referenced this issue Dec 4, 2023
When trying to create enough data for a full pipeline run for
osbuild#287 I struggled a bit
because it was not clear which items where faulty.

This commit adds more context to the errors. It uses the new
`assertx.PanicsWithErrorRegexp` that is needed because of
stretchr/testify#1304
(until fixed or contributed back).
github-merge-queue bot pushed a commit to osbuild/images that referenced this issue Dec 4, 2023
This adds a new internal package with `testify/assert` extensions.
It contains the new 'PanicsWithErrorRegexp()` helper that can
be removed once upstream stretchr/testify#1304
is fixed (or we contributed this back).

It could not be added to `internal/test` as it would have created
cyclic dependencies when importing from `pkg/osbuild`.
github-merge-queue bot pushed a commit to osbuild/images that referenced this issue Dec 4, 2023
When trying to create enough data for a full pipeline run for
#287 I struggled a bit
because it was not clear which items where faulty.

This commit adds more context to the errors. It uses the new
`assertx.PanicsWithErrorRegexp` that is needed because of
stretchr/testify#1304
(until fixed or contributed back).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pkg-assert Change related to package testify/assert
Projects
None yet
Development

No branches or pull requests

2 participants