summaryrefslogtreecommitdiff
path: root/internal/command/receivepack
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2020-05-08 15:40:18 -0700
committerStan Hu <stanhu@gmail.com>2020-05-08 15:40:18 -0700
commitc0cf314c5722a4f7ec0a1f355d23fa2511344989 (patch)
tree96898bec50690d0d34eb9ead815b8ef4a89a40ce /internal/command/receivepack
parent1adadc2e299529e805aae3dac7c2579b88c8dae7 (diff)
downloadgitlab-shell-sh-add-http-status-code.tar.gz
Fix race conditions in testssh-add-http-status-code
Calling logrus hook.LastEntry() can lead to race conditions. Use AllEntries instead: https://github.com/sirupsen/logrus/blob/60c74ad9be0d874af0ab0daef6ab07c5c5911f0d/hooks/test/test.go#L77 Closes https://gitlab.com/gitlab-org/gitlab-shell/-/issues/450
Diffstat (limited to 'internal/command/receivepack')
-rw-r--r--internal/command/receivepack/gitalycall_test.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index dd75176..fd062b2 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -2,7 +2,6 @@ package receivepack
import (
"bytes"
- "strings"
"testing"
"github.com/sirupsen/logrus"
@@ -43,7 +42,10 @@ func TestReceivePack(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "ReceivePack: "+userId+" "+repo, output.String())
- require.Equal(t, logrus.InfoLevel, hook.LastEntry().Level)
- require.True(t, strings.Contains(hook.LastEntry().Message, "executing git command"))
- require.True(t, strings.Contains(hook.LastEntry().Message, "command=git-receive-pack"))
+
+ entries := hook.AllEntries()
+ require.Equal(t, 2, len(entries))
+ require.Equal(t, logrus.InfoLevel, entries[1].Level)
+ require.Contains(t, entries[1].Message, "executing git command")
+ require.Contains(t, entries[1].Message, "command=git-receive-pack")
}