diff options
author | Nathan Friend <nathan@gitlab.com> | 2021-08-20 18:25:50 +0300 |
---|---|---|
committer | Nathan Friend <nathan@gitlab.com> | 2021-08-20 18:25:50 +0300 |
commit | 5b02827f0528bd79c943b1f6c0b47d23012ec826 (patch) | |
tree | 0923ad5e9614783efcbb25502d65ddd9b7f84d33 | |
parent | 96458b6f5841d8df17913a60dc7dbd266ac2100b (diff) |
Update benchmark tests to use enablePlaceholdersnfriend-update-enable-placeholders-test-helper
This commit updates the enablePlaceholders test helper so that is can
also be used by the benchmark tests.
-rw-r--r-- | internal/redirects/redirects_benchmark_test.go | 5 | ||||
-rw-r--r-- | internal/redirects/redirects_test.go | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/internal/redirects/redirects_benchmark_test.go b/internal/redirects/redirects_benchmark_test.go index 35e5cc25..38adcb68 100644 --- a/internal/redirects/redirects_benchmark_test.go +++ b/internal/redirects/redirects_benchmark_test.go @@ -4,7 +4,6 @@ import ( "context" "io/ioutil" "net/url" - "os" "path" "strings" "testing" @@ -56,9 +55,7 @@ func BenchmarkRedirectsRewrite_withoutPlaceholders(b *testing.B) { } func BenchmarkRedirectsRewrite_PlaceholdersEnabled(b *testing.B) { - orig := os.Getenv(FFEnablePlaceholders) - os.Setenv(FFEnablePlaceholders, "true") - b.Cleanup(func() { os.Setenv(FFEnablePlaceholders, orig) }) + enablePlaceholders(b) b.Run("10 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 10) }) b.Run("100 redirects", func(b *testing.B) { benchmarkRedirectsRewrite(b, 100) }) diff --git a/internal/redirects/redirects_test.go b/internal/redirects/redirects_test.go index 3287091c..6ae141f5 100644 --- a/internal/redirects/redirects_test.go +++ b/internal/redirects/redirects_test.go @@ -16,7 +16,7 @@ import ( ) // enablePlaceholders enables the FF_ENABLE_PLACEHOLDERS in tests -func enablePlaceholders(t *testing.T) { +func enablePlaceholders(t testing.TB) { t.Helper() orig := os.Getenv(FFEnablePlaceholders) |