summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/command/receivepack/gitalycall_test.go1
-rw-r--r--internal/command/uploadarchive/gitalycall_test.go2
-rw-r--r--internal/testhelper/testhelper.go16
3 files changed, 19 insertions, 0 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index fd062b2..0cfbf5c 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -43,6 +43,7 @@ func TestReceivePack(t *testing.T) {
require.Equal(t, "ReceivePack: "+userId+" "+repo, output.String())
+ require.True(t, testhelper.WaitForLogEvent(hook))
entries := hook.AllEntries()
require.Equal(t, 2, len(entries))
require.Equal(t, logrus.InfoLevel, entries[1].Level)
diff --git a/internal/command/uploadarchive/gitalycall_test.go b/internal/command/uploadarchive/gitalycall_test.go
index 8b60e11..488c390 100644
--- a/internal/command/uploadarchive/gitalycall_test.go
+++ b/internal/command/uploadarchive/gitalycall_test.go
@@ -42,6 +42,8 @@ func TestUploadPack(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "UploadArchive: "+repo, output.String())
+
+ require.True(t, testhelper.WaitForLogEvent(hook))
entries := hook.AllEntries()
require.Equal(t, 2, len(entries))
require.Equal(t, logrus.InfoLevel, entries[1].Level)
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
+}