From 097c4c0aec8ddb0028ed8be8ed338d87020c5a9b Mon Sep 17 00:00:00 2001 From: Vladimir Shushlin Date: Tue, 14 Dec 2021 15:02:13 +0300 Subject: refactor: extract common logic for env feature flags --- test/acceptance/ratelimiter_test.go | 3 ++- test/acceptance/redirects_test.go | 8 ++++---- test/acceptance/rewrites_test.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/acceptance/ratelimiter_test.go b/test/acceptance/ratelimiter_test.go index 5b3be98a..ae6184ca 100644 --- a/test/acceptance/ratelimiter_test.go +++ b/test/acceptance/ratelimiter_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) func TestSourceIPRateLimitMiddleware(t *testing.T) { - testhelpers.SetEnvironmentVariable(t, testhelpers.FFEnableRateLimiter, "true") + testhelpers.StubFeatureFlagValue(t, feature.EnforceIPRateLimits.EnvVariable, true) tcs := map[string]struct { listener ListenSpec diff --git a/test/acceptance/redirects_test.go b/test/acceptance/redirects_test.go index 0cadea16..685e0fcb 100644 --- a/test/acceptance/redirects_test.go +++ b/test/acceptance/redirects_test.go @@ -6,15 +6,15 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitlab-pages/internal/feature" - redirects "gitlab.com/gitlab-org/gitlab-pages/internal/redirects" + "github.com/stretchr/testify/require" ) func TestRedirectStatusPage(t *testing.T) { RunPagesProcess(t, withListeners([]ListenSpec{httpListener}), - withEnv([]string{redirects.FFEnablePlaceholders + "=true"}), + withEnv([]string{feature.RedirectsPlaceholders.EnvVariable + "=true"}), ) rsp, err := GetPageFromListener(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/_redirects") @@ -31,7 +31,7 @@ func TestRedirectStatusPage(t *testing.T) { func TestRedirect(t *testing.T) { RunPagesProcess(t, withListeners([]ListenSpec{httpListener}), - withEnv([]string{redirects.FFEnablePlaceholders + "=true"}), + withEnv([]string{feature.RedirectsPlaceholders.EnvVariable + "=true"}), ) // Test that serving a file still works with redirects enabled diff --git a/test/acceptance/rewrites_test.go b/test/acceptance/rewrites_test.go index 5ac16070..aa105789 100644 --- a/test/acceptance/rewrites_test.go +++ b/test/acceptance/rewrites_test.go @@ -7,13 +7,13 @@ import ( "github.com/stretchr/testify/require" - redirects "gitlab.com/gitlab-org/gitlab-pages/internal/redirects" + "gitlab.com/gitlab-org/gitlab-pages/internal/feature" ) func TestRewrites(t *testing.T) { RunPagesProcess(t, withListeners([]ListenSpec{httpListener}), - withEnv([]string{redirects.FFEnablePlaceholders + "=true"}), + withEnv([]string{feature.RedirectsPlaceholders.EnvVariable + "=true"}), ) tests := map[string]struct { -- cgit v1.2.3