summaryrefslogtreecommitdiff
path: root/internal/testhelper/testhelper.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/testhelper/testhelper.go')
-rw-r--r--internal/testhelper/testhelper.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index da781ce..5e98c1c 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -6,6 +6,7 @@ import (
"os"
"path"
"runtime"
+ "time"
"github.com/otiai10/copy"
"github.com/sirupsen/logrus"
@@ -100,3 +101,18 @@ func SetupLogger() *test.Hook {
return hook
}
+
+// logrus fires a Goroutine to write the output log, but there's no way to
+// flush all outstanding hooks to fire. We just wait up to a second
+// for an event to appear.
+func WaitForLogEvent(hook *test.Hook) bool {
+ for i := 0; i < 10; i++ {
+ if entry := hook.LastEntry(); entry != nil {
+ return true
+ }
+
+ time.Sleep(100*time.Millisecond)
+ }
+
+ return false
+}