|
1 | 1 | package htransformation_test
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "context" |
5 | 4 | "net/http"
|
6 | 5 | "net/http/httptest"
|
7 | 6 | "testing"
|
@@ -99,7 +98,7 @@ func TestValidation(t *testing.T) {
|
99 | 98 | t.Run(test.name, func(t *testing.T) {
|
100 | 99 | t.Parallel()
|
101 | 100 |
|
102 |
| - _, err := plug.New(context.Background(), nil, test.config, "test") |
| 101 | + _, err := plug.New(t.Context(), nil, test.config, "test") |
103 | 102 | if test.wantErr {
|
104 | 103 | assert.Error(t, err)
|
105 | 104 | } else {
|
@@ -164,15 +163,14 @@ func TestHeaderRules(t *testing.T) {
|
164 | 163 | cfg := plug.CreateConfig()
|
165 | 164 | cfg.Rules = []types.Rule{test.rule}
|
166 | 165 |
|
167 |
| - ctx := context.Background() |
168 | 166 | next := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
|
169 | 167 |
|
170 |
| - handler, err := plug.New(ctx, next, cfg, "demo-plugin") |
| 168 | + handler, err := plug.New(t.Context(), next, cfg, "demo-plugin") |
171 | 169 | require.NoError(t, err)
|
172 | 170 |
|
173 | 171 | recorder := httptest.NewRecorder()
|
174 | 172 |
|
175 |
| - req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost", nil) |
| 173 | + req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://localhost", nil) |
176 | 174 | require.NoError(t, err)
|
177 | 175 |
|
178 | 176 | for key, value := range test.additionalHeader {
|
@@ -239,18 +237,17 @@ func TestSetOnResponse(t *testing.T) {
|
239 | 237 | cfg := plug.CreateConfig()
|
240 | 238 | cfg.Rules = []types.Rule{test.rule}
|
241 | 239 |
|
242 |
| - ctx := context.Background() |
243 | 240 | next := http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
|
244 | 241 | rw.Header().Add(test.headerName, test.headerValue)
|
245 | 242 | rw.WriteHeader(http.StatusOK)
|
246 | 243 | })
|
247 | 244 |
|
248 |
| - handler, err := plug.New(ctx, next, cfg, "demo-plugin") |
| 245 | + handler, err := plug.New(t.Context(), next, cfg, "demo-plugin") |
249 | 246 | require.NoError(t, err)
|
250 | 247 |
|
251 | 248 | recorder := httptest.NewRecorder()
|
252 | 249 |
|
253 |
| - req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost", nil) |
| 250 | + req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://localhost", nil) |
254 | 251 | require.NoError(t, err)
|
255 | 252 |
|
256 | 253 | handler.ServeHTTP(recorder, req)
|
|
0 commit comments