diff options
author | Nathan Friend <hello@nathanfriend.io> | 2021-08-21 19:46:01 +0300 |
---|---|---|
committer | Nathan Friend <hello@nathanfriend.io> | 2021-08-21 19:46:01 +0300 |
commit | 340d1de11bc7267083f27f317ba8efac62872f0a (patch) | |
tree | 0923ad5e9614783efcbb25502d65ddd9b7f84d33 /internal/redirects | |
parent | 96458b6f5841d8df17913a60dc7dbd266ac2100b (diff) |
refactor: Update benchmark tests to use helper
This commit updates the enablePlaceholders test helper so that it can
also be used by the benchmark tests.
Diffstat (limited to 'internal/redirects')
-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) |