fix: background reader apart from global handler for testing (#1929)

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
Christopher Angelo Phillips
2023-07-12 12:37:19 -04:00
committed by GitHub
parent 05a61897f2
commit 38efe4ec5f
3 changed files with 32 additions and 17 deletions
+8 -1
View File
@@ -2,13 +2,14 @@ package ui
import (
"reflect"
"sync"
"testing"
"unsafe"
tea "github.com/charmbracelet/bubbletea"
)
func runModel(t testing.TB, m tea.Model, iterations int, message tea.Msg) string {
func runModel(t testing.TB, m tea.Model, iterations int, message tea.Msg, h ...*sync.WaitGroup) string {
t.Helper()
if iterations == 0 {
iterations = 1
@@ -29,6 +30,12 @@ func runModel(t testing.TB, m tea.Model, iterations int, message tea.Msg) string
}
cmd = tea.Batch(nextCmds...)
}
for _, each := range h {
if each != nil {
each.Wait()
}
}
return m.View()
}