(t *testing.T)
| 1225 | } |
| 1226 | |
| 1227 | func TestDoRequestNewWay(t *testing.T) { |
| 1228 | reqBody := "request body" |
| 1229 | expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{ |
| 1230 | Protocol: "TCP", |
| 1231 | Port: 12345, |
| 1232 | TargetPort: intstr.FromInt(12345), |
| 1233 | }}}} |
| 1234 | expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj) |
| 1235 | fakeHandler := utiltesting.FakeHandler{ |
| 1236 | StatusCode: 200, |
| 1237 | ResponseBody: string(expectedBody), |
| 1238 | T: t, |
| 1239 | } |
| 1240 | testServer := httptest.NewServer(&fakeHandler) |
| 1241 | defer testServer.Close() |
| 1242 | c := testRESTClient(t, testServer) |
| 1243 | obj, err := c.Verb("POST"). |
| 1244 | Prefix("foo", "bar"). |
| 1245 | Suffix("baz"). |
| 1246 | Timeout(time.Second). |
| 1247 | Body([]byte(reqBody)). |
| 1248 | Do().Get() |
| 1249 | if err != nil { |
| 1250 | t.Errorf("Unexpected error: %v %#v", err, err) |
| 1251 | return |
| 1252 | } |
| 1253 | if obj == nil { |
| 1254 | t.Error("nil obj") |
| 1255 | } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) { |
| 1256 | t.Errorf("Expected: %#v, got %#v", expectedObj, obj) |
| 1257 | } |
| 1258 | requestURL := defaultResourcePathWithPrefix("foo/bar", "", "", "baz") |
| 1259 | requestURL += "?timeout=1s" |
| 1260 | fakeHandler.ValidateRequest(t, requestURL, "POST", &reqBody) |
| 1261 | } |
| 1262 | |
| 1263 | // This test assumes that the client implementation backs off exponentially, for an individual request. |
| 1264 | func TestBackoffLifecycle(t *testing.T) { |
nothing calls this directly
no test coverage detected