Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-09 14:33:03 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-14 09:54:12 +0300
commit08d5b7b268e36da27a7843a1c7d7021ef9a96487 (patch)
treecc0a2dbcaf62b6848659299915d5220d21fb8668 /internal/gitlab
parent8907e9a9637182efa7576024008882e790c77c89 (diff)
tests: Convert to use testhelper contexts
We're about to disallow use of "normal" contexts created via the `context` package given that they do not perform sanity checks for feature flags. Instead, contexts should be created via the testhelper package. Convert tests to use the testhelper context.
Diffstat (limited to 'internal/gitlab')
-rw-r--r--internal/gitlab/http_client_test.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/internal/gitlab/http_client_test.go b/internal/gitlab/http_client_test.go
index 7d2c6bfc9..90f9e96f0 100644
--- a/internal/gitlab/http_client_test.go
+++ b/internal/gitlab/http_client_test.go
@@ -1,7 +1,6 @@
package gitlab
import (
- "context"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -120,8 +119,11 @@ func TestAccess_verifyParams(t *testing.T) {
},
}
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
for _, tc := range testCases {
- allowed, _, err := c.Allowed(context.Background(), AllowedParams{
+ allowed, _, err := c.Allowed(ctx, AllowedParams{
RepoPath: tc.repo.RelativePath,
GitObjectDirectory: tc.repo.GitObjectDirectory,
GitAlternateObjectDirectories: tc.repo.GitAlternateObjectDirectories,
@@ -227,7 +229,11 @@ func TestAccess_escapedAndRelativeURLs(t *testing.T) {
prometheus.Config{},
)
require.NoError(t, err)
- allowed, _, err := c.Allowed(context.Background(), AllowedParams{
+
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
+ allowed, _, err := c.Allowed(ctx, AllowedParams{
RepoPath: repo.RelativePath,
GitObjectDirectory: repo.GitObjectDirectory,
GitAlternateObjectDirectories: repo.GitAlternateObjectDirectories,
@@ -379,7 +385,10 @@ func TestAccess_allowedResponseHandling(t *testing.T) {
mockHistogramVec := promtest.NewMockHistogramVec()
c.latencyMetric = mockHistogramVec
- allowed, message, err := c.Allowed(context.Background(), AllowedParams{
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
+ allowed, message, err := c.Allowed(ctx, AllowedParams{
RepoPath: repo.RelativePath,
GitObjectDirectory: repo.GitObjectDirectory,
GitAlternateObjectDirectories: repo.GitAlternateObjectDirectories,
@@ -489,7 +498,10 @@ func TestAccess_preReceive(t *testing.T) {
mockHistogramVec := promtest.NewMockHistogramVec()
c.latencyMetric = mockHistogramVec
- success, err := c.PreReceive(context.Background(), "key-123")
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
+ success, err := c.PreReceive(ctx, "key-123")
require.Equal(t, tc.success, success)
if err != nil {
require.Contains(t, err.Error(), tc.errMsg)
@@ -577,10 +589,13 @@ func TestAccess_postReceive(t *testing.T) {
mockHistogramVec := promtest.NewMockHistogramVec()
c.latencyMetric = mockHistogramVec
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
repositoryID := "project-123"
identifier := "key-123"
changes := "000 000 refs/heads/master"
- success, _, err := c.PostReceive(context.Background(), repositoryID, identifier, changes, tc.pushOptions...)
+ success, _, err := c.PostReceive(ctx, repositoryID, identifier, changes, tc.pushOptions...)
require.Equal(t, tc.success, success)
if err != nil {
require.Contains(t, err.Error(), tc.errMsg)