Improve error handling in concurrency test

Refactor goroutine error handling in downloader tests.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Anis Khan <2815766+aniskhan001@users.noreply.github.com>
pull/32533/head
Anis Khan 2 weeks ago committed by GitHub
parent 48712bc8ca
commit 07e7a4c2e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -388,19 +388,26 @@ func TestTmpChartsDirConcurrent(t *testing.T) {
const concurrency = 32
paths := make([]string, concurrency)
errs := make([]error, concurrency)
var wg sync.WaitGroup
for i := 0; i < concurrency; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
path, err := tmpChartsDir(chartPath)
require.NoError(t, err)
paths[i] = path
require.NoError(t, os.RemoveAll(path))
if err == nil {
paths[i] = path
err = os.RemoveAll(path)
}
errs[i] = err
}(i)
}
wg.Wait()
for i, err := range errs {
require.NoError(t, err, "tmpChartsDir goroutine %d failed", i)
}
seen := make(map[string]struct{}, concurrency)
for _, path := range paths {
require.NotEmpty(t, path)
@ -408,7 +415,6 @@ func TestTmpChartsDirConcurrent(t *testing.T) {
require.False(t, dup, "duplicate tmp dir: %s", path)
seen[path] = struct{}{}
}
}
func TestLockForChartPathEquivalentPaths(t *testing.T) {
chartPath := t.TempDir()

Loading…
Cancel
Save