-
Notifications
You must be signed in to change notification settings - Fork 15
Enhance test assertion failure messages with actual/expected values #803
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
Conversation
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
@copilot add changelog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves test failure messages by incorporating actual and expected values into assertion errors.
- Test assertions in provider_test.go now use require.Equalf and require.Containsf with formatted messages
- Error messages reveal specific discrepancies in data sources and resources counts
Comments suppressed due to low confidence (2)
internal/provider/provider_test.go:81
- [nitpick] Consider rephrasing the error message to clarify that the data source was expected but not found; for example, 'Data source %+v not found in expected data sources' may improve readability.
require.Containsf(t, expectedDataSources, d(), "Data source %+v was not expected", d())
internal/provider/provider_test.go:113
- [nitpick] Consider rephrasing the error message to better indicate that the resource was expected to be present but was missing; for example, 'Resource %+v not found in expected resources' would be clearer.
require.Containsf(t, expectedResources, r(), "Resource %+v was not expected", r())
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The test functions in
internal/provider/provider_test.go
were using generic failure messages that made debugging difficult when assertions failed. This change replaces the generic messages with descriptive ones that include actual and expected values.Changes Made
Before:
After:
Impact
When tests fail, developers will now see specific information like:
This provides immediate context about what went wrong, making debugging much faster and more efficient.
Fixes #802.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint-api.hashicorp.com
/tmp/go-build1791408922/b001/provider.test -test.testlogfile=/tmp/go-build1791408922/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=TestUnit.*
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.