-
Notifications
You must be signed in to change notification settings - Fork 812
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
persistence/client/factory.go test coverage #5859
Conversation
Codecov Report
Additional details and impacted files
... and 25 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Pull Request Test Coverage Report for Build 018ebf5a-5f3f-4557-b52c-6a13a84b8aceDetails
💛 - Coveralls |
@@ -18,6 +18,8 @@ | |||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
// THE SOFTWARE. | |||
|
|||
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination factory_mock.go |
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.
unfortunately mockgen
doesn't seem to allow choosing the interfaces.
I only need the DataStoreFactory
.
if testing.Verbose() { | ||
logger, err := loggerimpl.NewDevelopment() | ||
require.NoError(t, err) | ||
return logger | ||
} |
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.
This is a very problematic thing to do in general, and almost certainly should never have been written or approved in the first place.
Verbose test mode already streams the outputs of every t.Log
, and they are nicely contained within the test that produced the log if you use a t.Log
-based logger. This just spams stdout, interleaving everything with no way to correlate outputs (if concurrent).
Since CI runs tests verbosely this might lead to more race failures in tests, as it touches *testing.T
more than it did before, and there are quite a lot of async logging goroutines that are not cleanly shut down across this repo.
If that happens and proves onerous to fix or work around, we could undo this. So far I haven't seen other tests fail due to this change though.
Our ability to cover this file is rather harshly limited due to it directly calling funcs in other packages that try to make network connections... but thankfully the DataStore-based stuff can be intercepted. So I've at least tested those branches.
More generally this package is yet another strong argument in favor of leaning more on go.uber.org/fx for dependency injection. Very little of this has to be (or should be) hard-coded in this file. It feels like Java's "Service Locator" pattern, but even worse because the language doesn't allow test controls of globals like Java does... so I doubt it's a coincidence that there's a
bean.go
file in here.