33c205be4f
staticcheck go linter warns: > distribution/xfer/transfer_test.go:37:2: SA2002: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (staticcheck) What it doesn't say is why. The reason is, t.Fatalf() calls t.FailNow(), which is expected to stop test execution right now. It does so by calling runtime.Goexit(), which, unless called from a main goroutine, does not stop test execution. Anyway, long story short, if we don't care much about stopping the test case immediately, we can just replace t.Fatalf() with t.Errorf() which still marks the test case as failed, but won't stop it immediately. This patch was tested to check that the test fails if any of the goroutines call t.Errorf(): 1. Failure in DoFunc ("transfer function not started ...") was tested by decreading the NewTransferManager() argument: - tm := NewTransferManager(5) + tm := NewTransferManager(2) 2. Failure "got unexpected progress value" was tested by injecting a random: - if present && p.Current <= val { + if present && p.Current <= val || rand.Intn(100) > 80 { 3. Failure in DoFunc ("too many jobs running") was tested by increasing the NewTransferManager() argument: - tm := NewTransferManager(concurrencyLimit) + tm := NewTransferManager(concurrencyLimit + 1) While at it: * fix/amend some error messages * use _ for unused arguments of DoFunc Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> |
||
---|---|---|
.. | ||
download.go | ||
download_test.go | ||
transfer.go | ||
transfer_test.go | ||
upload.go | ||
upload_test.go |