Skip to content

Commit 5ef01fa

Browse files
Guangming Wangcamilamacedo86
authored andcommitted
fix t.Fataf using in goroutine (#1957)
rename err chan Signed-off-by: Guangming Wang <[email protected]>
1 parent ed63729 commit 5ef01fa

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

internal/pkg/scaffold/helm/chart_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"net/http"
2121
"os"
2222
"path/filepath"
23-
"sync"
2423
"testing"
2524
"time"
2625

@@ -80,13 +79,9 @@ func TestCreateChart(t *testing.T) {
8079
repoURLCharts = fmt.Sprintf("http://%s/charts/", testRepo.Addr)
8180
)
8281

83-
var wg sync.WaitGroup
84-
wg.Add(1)
82+
testRepoServerErrChan := make(chan error)
8583
go func() {
86-
if err := testRepo.ListenAndServe(); err != nil && err != http.ErrServerClosed {
87-
t.Fatalf("Failed to run test repo server: %s", err)
88-
}
89-
wg.Done()
84+
testRepoServerErrChan <- testRepo.ListenAndServe()
9085
}()
9186

9287
testCases := []createChartTestCase{
@@ -254,7 +249,10 @@ func TestCreateChart(t *testing.T) {
254249
if err := testRepo.Close(); err != nil {
255250
t.Fatalf("Failed to close test repo server: %s", err)
256251
}
257-
wg.Wait()
252+
253+
if err := <-testRepoServerErrChan; err != nil && err != http.ErrServerClosed {
254+
t.Fatalf("Failed to run test repo server: %s", err)
255+
}
258256
}
259257

260258
type testChart struct {

0 commit comments

Comments
 (0)