call TestApp.ResetBootstrap as finalizer of the test OnTerminate hook

This commit is contained in:
Gani Georgiev
2024-03-20 23:47:19 +02:00
parent 03cec9a5ac
commit 309c4fe6fe
2 changed files with 13 additions and 5 deletions
+6 -1
View File
@@ -1279,7 +1279,7 @@ func (app *BaseApp) initLogger() error {
for {
select {
case <-done:
handler.WriteAll(ctx)
return
case <-ticker.C:
handler.WriteAll(ctx)
}
@@ -1289,8 +1289,13 @@ func (app *BaseApp) initLogger() error {
app.logger = slog.New(handler)
app.OnTerminate().PreAdd(func(e *TerminateEvent) error {
// write all remaining logs before ticker.Stop to avoid races with ResetBootstrap user calls
handler.WriteAll(context.Background())
ticker.Stop()
done <- true
return nil
})