Skip to content

Commit

Permalink
further simplify names where test is run to have single source of tru…
Browse files Browse the repository at this point in the history
…th (the name retreived from reflection)
  • Loading branch information
jasondborneman committed Jan 16, 2024
1 parent ecf2768 commit c7e707a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions example/weather/services/tester/run_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ func (svc *Service) runTests(ctx context.Context, p *gentester.TesterPayload, te
return testName
}
defer recoverFromTestPanic(ctx, testNameFunc, testCollection)
for name, test := range testsToRun {
for _, test := range testsToRun {
testName = getTestName(test)
log.Infof(ctx, "RUNNING TEST [%v]", name)
log.Infof(ctx, "RUNNING TEST [%v]", testName)
test(ctx, testCollection)
}
}()
Expand All @@ -232,19 +232,19 @@ func (svc *Service) runTests(ctx context.Context, p *gentester.TesterPayload, te
// contention
log.Infof(ctx, "RUNNING TESTS IN PARALLEL")
wg := sync.WaitGroup{}
for name, test := range testsToRun {
for _, test := range testsToRun {
wg.Add(1)
go func(f func(context.Context, *TestCollection), testNameRunning string) {
go func(f func(context.Context, *TestCollection)) {
defer wg.Done()
testName := ""
testNameFunc := func() string {
return testName
}
defer recoverFromTestPanic(ctx, testNameFunc, testCollection)
testName = getTestName(f)
log.Infof(ctx, "RUNNING TEST [%v]", testNameRunning)
log.Infof(ctx, "RUNNING TEST [%v]", testName)
f(ctx, testCollection)
}(test, name)
}(test)
}
wg.Wait()
}
Expand Down

0 comments on commit c7e707a

Please sign in to comment.