cleanup req.Context() and ResponseWrapper

Kubernetes-commit: 968adfa99362f733ef82f4aabb34a59dbbd6e56a
This commit is contained in:
Mike Danese
2020-01-27 18:52:27 -08:00
committed by Kubernetes Publisher
parent b136e9eb2b
commit 09009e85ca
12 changed files with 39 additions and 49 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package rest
import (
"context"
"net/http"
"net/http/httptest"
"net/url"
@@ -79,7 +80,7 @@ func TestDoRequestSuccess(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
body, err := c.Get().Prefix("test").Do().Raw()
body, err := c.Get().Prefix("test").Do(context.Background()).Raw()
testParam := TestParam{actualError: err, expectingError: false, expCreated: true,
expStatus: status, testBody: true, testBodyErrorIsNotNil: false}
@@ -107,7 +108,7 @@ func TestDoRequestFailed(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
err = c.Get().Do().Error()
err = c.Get().Do(context.Background()).Error()
if err == nil {
t.Errorf("unexpected non-error")
}
@@ -146,7 +147,7 @@ func TestDoRawRequestFailed(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
body, err := c.Get().Do().Raw()
body, err := c.Get().Do(context.Background()).Raw()
if err == nil || body == nil {
t.Errorf("unexpected non-error: %#v", body)
@@ -170,7 +171,7 @@ func TestDoRequestCreated(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
created := false
body, err := c.Get().Prefix("test").Do().WasCreated(&created).Raw()
body, err := c.Get().Prefix("test").Do(context.Background()).WasCreated(&created).Raw()
testParam := TestParam{actualError: err, expectingError: false, expCreated: true,
expStatus: status, testBody: false}
@@ -185,7 +186,7 @@ func TestDoRequestNotCreated(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
created := false
body, err := c.Get().Prefix("test").Do().WasCreated(&created).Raw()
body, err := c.Get().Prefix("test").Do(context.Background()).WasCreated(&created).Raw()
testParam := TestParam{actualError: err, expectingError: false, expCreated: false,
expStatus: expectedStatus, testBody: false}
validate(testParam, t, body, fakeHandler)
@@ -200,7 +201,7 @@ func TestDoRequestAcceptedNoContentReturned(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
created := false
body, err := c.Get().Prefix("test").Do().WasCreated(&created).Raw()
body, err := c.Get().Prefix("test").Do(context.Background()).WasCreated(&created).Raw()
testParam := TestParam{actualError: err, expectingError: false, expCreated: false,
testBody: false}
validate(testParam, t, body, fakeHandler)
@@ -214,7 +215,7 @@ func TestBadRequest(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
created := false
body, err := c.Get().Prefix("test").Do().WasCreated(&created).Raw()
body, err := c.Get().Prefix("test").Do(context.Background()).WasCreated(&created).Raw()
testParam := TestParam{actualError: err, expectingError: true, expCreated: false,
testBody: true}
validate(testParam, t, body, fakeHandler)