diff options
author | David Kim <dkim@gitlab.com> | 2020-03-30 19:06:23 +1030 |
---|---|---|
committer | David Kim <dkim@gitlab.com> | 2020-03-30 19:06:23 +1030 |
commit | 3f3a405c181840e2de13ffb22f7a50fd78054dc0 (patch) | |
tree | 29fce1b63df3ffa4ca242fc6152666a0b92a7882 | |
parent | 90fe3a0bd925be0272d92f3ac6f555dd5837cf9e (diff) | |
download | gitlab-shell-3f3a405c181840e2de13ffb22f7a50fd78054dc0.tar.gz |
Add tests for logging
-rw-r--r-- | internal/command/receivepack/gitalycall_test.go | 8 | ||||
-rw-r--r-- | internal/command/uploadarchive/gitalycall_test.go | 8 | ||||
-rw-r--r-- | internal/command/uploadpack/gitalycall_test.go | 8 |
3 files changed, 24 insertions, 0 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go index de20bfd..a20e858 100644 --- a/internal/command/receivepack/gitalycall_test.go +++ b/internal/command/receivepack/gitalycall_test.go @@ -3,6 +3,9 @@ package receivepack import ( "bytes" "testing" + "strings" + + "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" @@ -11,6 +14,7 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper/requesthandlers" + "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" ) func TestReceivePack(t *testing.T) { @@ -33,8 +37,12 @@ func TestReceivePack(t *testing.T) { ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } + hook := testhelper.SetupLogger() + err := cmd.Execute() 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")) } diff --git a/internal/command/uploadarchive/gitalycall_test.go b/internal/command/uploadarchive/gitalycall_test.go index 5345119..15122c7 100644 --- a/internal/command/uploadarchive/gitalycall_test.go +++ b/internal/command/uploadarchive/gitalycall_test.go @@ -3,6 +3,9 @@ package uploadarchive import ( "bytes" "testing" + "strings" + + "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" @@ -11,6 +14,7 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper/requesthandlers" + "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" ) func TestUploadPack(t *testing.T) { @@ -33,8 +37,12 @@ func TestUploadPack(t *testing.T) { ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } + hook := testhelper.SetupLogger() + err := cmd.Execute() require.NoError(t, err) require.Equal(t, "UploadArchive: "+repo, output.String()) + require.Equal(t, logrus.InfoLevel, hook.LastEntry().Level) + require.True(t, strings.Contains(hook.LastEntry().Message, "executing git command")) } diff --git a/internal/command/uploadpack/gitalycall_test.go b/internal/command/uploadpack/gitalycall_test.go index 8c74212..86dfbf1 100644 --- a/internal/command/uploadpack/gitalycall_test.go +++ b/internal/command/uploadpack/gitalycall_test.go @@ -3,6 +3,9 @@ package uploadpack import ( "bytes" "testing" + "strings" + + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -12,6 +15,7 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper/requesthandlers" + "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" ) func TestUploadPack(t *testing.T) { @@ -34,10 +38,14 @@ func TestUploadPack(t *testing.T) { ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } + hook := testhelper.SetupLogger() + err := cmd.Execute() require.NoError(t, err) require.Equal(t, "UploadPack: "+repo, output.String()) + require.Equal(t, logrus.InfoLevel, hook.LastEntry().Level) + require.True(t, strings.Contains(hook.LastEntry().Message, "executing git command")) for k, v := range map[string]string{ "gitaly-feature-cache_invalidator": "true", |