From 5b02827f0528bd79c943b1f6c0b47d23012ec826 Mon Sep 17 00:00:00 2001 From: Nathan Friend Date: Fri, 20 Aug 2021 11:25:50 -0400 Subject: Update benchmark tests to use enablePlaceholders This commit updates the enablePlaceholders test helper so that is can also be used by the benchmark tests. --- internal/redirects/redirects_benchmark_test.go | 5 +---- 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) -- cgit v1.2.3