Merge pull request #28587 from wojtek-t/remove_codec_from_content_config
Automatic merge from submit-queue Remove Codec from ContentConfig. This is the remaining cleanup after adding NegotiatedSerializer to ContentConfig.
This commit is contained in:
@@ -389,7 +389,7 @@ func TestAnnotateErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
for k, testCase := range testCases {
|
||||
f, tf, _ := NewAPIFactory()
|
||||
f, tf, _, _ := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
|
||||
@@ -419,10 +419,10 @@ func TestAnnotateErrors(t *testing.T) {
|
||||
func TestAnnotateObject(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.Method {
|
||||
case "GET":
|
||||
@@ -469,10 +469,10 @@ func TestAnnotateObject(t *testing.T) {
|
||||
func TestAnnotateObjectFromFile(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.Method {
|
||||
case "GET":
|
||||
@@ -520,10 +520,10 @@ func TestAnnotateObjectFromFile(t *testing.T) {
|
||||
func TestAnnotateMultipleObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.Method {
|
||||
case "GET":
|
||||
|
@@ -41,7 +41,7 @@ import (
|
||||
func TestApplyExtraArgsFail(t *testing.T) {
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
c := NewCmdApply(f, buf)
|
||||
if validateApplyArgs(c, []string{"rc"}) == nil {
|
||||
t.Fatalf("unexpected non-error")
|
||||
@@ -182,10 +182,10 @@ func TestApplyObject(t *testing.T) {
|
||||
nameRC, currentRC := readAndAnnotateReplicationController(t, filenameRC)
|
||||
pathRC := "/namespaces/test/replicationcontrollers/" + nameRC
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == pathRC && m == "GET":
|
||||
@@ -224,10 +224,10 @@ func TestApplyRetry(t *testing.T) {
|
||||
firstPatch := true
|
||||
retry := false
|
||||
getCount := 0
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == pathRC && m == "GET":
|
||||
@@ -276,10 +276,10 @@ func TestApplyNonExistObject(t *testing.T) {
|
||||
pathRC := "/namespaces/test/replicationcontrollers"
|
||||
pathNameRC := pathRC + "/" + nameRC
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == pathNameRC && m == "GET":
|
||||
@@ -323,10 +323,10 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
|
||||
nameSVC, currentSVC := readAndAnnotateService(t, filenameSVC)
|
||||
pathSVC := "/namespaces/test/services/" + nameSVC
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == pathRC && m == "GET":
|
||||
|
@@ -95,10 +95,10 @@ func TestPodAndContainerAttach(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{}
|
||||
@@ -161,9 +161,9 @@ func TestAttach(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
@@ -239,9 +239,9 @@ func TestAttachWarnings(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
|
@@ -28,7 +28,7 @@ func TestSetupOutputWriterNoOp(t *testing.T) {
|
||||
tests := []string{"", "-"}
|
||||
for _, test := range tests {
|
||||
out := &bytes.Buffer{}
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
cmd := NewCmdClusterInfoDump(f, os.Stdout)
|
||||
cmd.Flag("output-directory").Value.Set(test)
|
||||
writer := setupOutputWriter(cmd, out, "/some/file/that/should/be/ignored")
|
||||
@@ -48,7 +48,7 @@ func TestSetupOutputWriterFile(t *testing.T) {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
out := &bytes.Buffer{}
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
cmd := NewCmdClusterInfoDump(f, os.Stdout)
|
||||
cmd.Flag("output-directory").Value.Set(dir)
|
||||
writer := setupOutputWriter(cmd, out, file)
|
||||
|
@@ -190,13 +190,16 @@ type testFactory struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec, runtime.NegotiatedSerializer) {
|
||||
scheme, mapper, codec := newExternalScheme()
|
||||
t := &testFactory{
|
||||
Validator: validation.NullSchema{},
|
||||
Mapper: mapper,
|
||||
Typer: scheme,
|
||||
}
|
||||
negotiatedSerializer := serializer.NegotiatedSerializerWrapper(
|
||||
runtime.SerializerInfo{Serializer: codec},
|
||||
runtime.StreamSerializerInfo{})
|
||||
return &cmdutil.Factory{
|
||||
Object: func(discovery bool) (meta.RESTMapper, runtime.ObjectTyper) {
|
||||
priorityRESTMapper := meta.PriorityRESTMapper{
|
||||
@@ -234,11 +237,11 @@ func NewTestFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
ClientConfig: func() (*restclient.Config, error) {
|
||||
return t.ClientConfig, t.Err
|
||||
},
|
||||
}, t, codec
|
||||
}, t, codec, negotiatedSerializer
|
||||
}
|
||||
|
||||
func NewMixedFactory(apiClient resource.RESTClient) (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
f, t, c := NewTestFactory()
|
||||
f, t, c, _ := NewTestFactory()
|
||||
var multiRESTMapper meta.MultiRESTMapper
|
||||
multiRESTMapper = append(multiRESTMapper, t.Mapper)
|
||||
multiRESTMapper = append(multiRESTMapper, testapi.Default.RESTMapper())
|
||||
@@ -263,7 +266,7 @@ func NewMixedFactory(apiClient resource.RESTClient) (*cmdutil.Factory, *testFact
|
||||
return f, t, c
|
||||
}
|
||||
|
||||
func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec, runtime.NegotiatedSerializer) {
|
||||
t := &testFactory{
|
||||
Validator: validation.NullSchema{},
|
||||
}
|
||||
@@ -335,7 +338,7 @@ func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
|
||||
f.LabelsForObject = rf.LabelsForObject
|
||||
f.CanBeExposed = rf.CanBeExposed
|
||||
f.PrintObjectSpecificMessage = rf.PrintObjectSpecificMessage
|
||||
return f, t, testapi.Default.Codec()
|
||||
return f, t, testapi.Default.Codec(), testapi.Default.NegotiatedSerializer()
|
||||
}
|
||||
|
||||
func objBody(codec runtime.Codec, obj runtime.Object) io.ReadCloser {
|
||||
@@ -367,11 +370,11 @@ func stringBody(body string) io.ReadCloser {
|
||||
//}
|
||||
|
||||
func Example_printReplicationControllerWithNamespace() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
ctrl := &api.ReplicationController{
|
||||
@@ -413,11 +416,11 @@ func Example_printReplicationControllerWithNamespace() {
|
||||
}
|
||||
|
||||
func Example_printMultiContainersReplicationControllerWithWide() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, false, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
ctrl := &api.ReplicationController{
|
||||
@@ -462,11 +465,11 @@ func Example_printMultiContainersReplicationControllerWithWide() {
|
||||
}
|
||||
|
||||
func Example_printReplicationController() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
ctrl := &api.ReplicationController{
|
||||
@@ -511,11 +514,11 @@ func Example_printReplicationController() {
|
||||
}
|
||||
|
||||
func Example_printPodWithWideFormat() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, true, false, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
nodeName := "kubernetes-minion-abcd"
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
@@ -548,11 +551,11 @@ func Example_printPodWithWideFormat() {
|
||||
}
|
||||
|
||||
func Example_printPodWithShowLabels() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, true, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
nodeName := "kubernetes-minion-abcd"
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
@@ -680,11 +683,11 @@ func newAllPhasePodList() *api.PodList {
|
||||
}
|
||||
|
||||
func Example_printPodHideTerminated() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, false, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
podList := newAllPhasePodList()
|
||||
@@ -701,11 +704,11 @@ func Example_printPodHideTerminated() {
|
||||
}
|
||||
|
||||
func Example_printPodShowAll() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, false, false, true, false, false, []string{})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
podList := newAllPhasePodList()
|
||||
@@ -724,11 +727,11 @@ func Example_printPodShowAll() {
|
||||
}
|
||||
|
||||
func Example_printServiceWithNamespacesAndLabels() {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(false, true, false, false, false, false, []string{"l1"})
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: nil,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: nil,
|
||||
}
|
||||
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
|
||||
svc := &api.ServiceList{
|
||||
|
@@ -28,10 +28,10 @@ import (
|
||||
func TestCreateConfigMap(t *testing.T) {
|
||||
configMap := &api.ConfigMap{}
|
||||
configMap.Name = "my-configmap"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/configmaps" && m == "POST":
|
||||
|
@@ -28,10 +28,10 @@ import (
|
||||
func TestCreateNamespace(t *testing.T) {
|
||||
namespaceObject := &api.Namespace{}
|
||||
namespaceObject.Name = "my-namespace"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces" && m == "POST":
|
||||
|
@@ -28,10 +28,10 @@ import (
|
||||
func TestCreateSecretGeneric(t *testing.T) {
|
||||
secretObject := &api.Secret{}
|
||||
secretObject.Name = "my-secret"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/secrets" && m == "POST":
|
||||
@@ -56,10 +56,10 @@ func TestCreateSecretGeneric(t *testing.T) {
|
||||
func TestCreateSecretDockerRegistry(t *testing.T) {
|
||||
secretObject := &api.Secret{}
|
||||
secretObject.Name = "my-secret"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/secrets" && m == "POST":
|
||||
|
@@ -28,10 +28,10 @@ import (
|
||||
func TestCreateServiceAccount(t *testing.T) {
|
||||
serviceAccountObject := &api.ServiceAccount{}
|
||||
serviceAccountObject.Name = "my-service-account"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/serviceaccounts" && m == "POST":
|
||||
|
@@ -28,7 +28,7 @@ func TestExtraArgsFail(t *testing.T) {
|
||||
initTestErrorHandler(t)
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
c := NewCmdCreate(f, buf)
|
||||
if ValidateArgs(c, []string{"rc"}) == nil {
|
||||
t.Errorf("unexpected non-error")
|
||||
@@ -40,10 +40,10 @@ func TestCreateObject(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
rc.Items[0].Name = "redis-master-controller"
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers" && m == "POST":
|
||||
@@ -72,10 +72,10 @@ func TestCreateMultipleObject(t *testing.T) {
|
||||
initTestErrorHandler(t)
|
||||
_, svc, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/services" && m == "POST":
|
||||
@@ -108,10 +108,10 @@ func TestCreateDirectory(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
rc.Items[0].Name = "name"
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers" && m == "POST":
|
||||
|
@@ -33,10 +33,10 @@ import (
|
||||
func TestDeleteObjectByTuple(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master-controller" && m == "DELETE":
|
||||
@@ -65,10 +65,10 @@ func TestDeleteObjectByTuple(t *testing.T) {
|
||||
func TestDeleteNamedObject(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master-controller" && m == "DELETE":
|
||||
@@ -97,10 +97,10 @@ func TestDeleteNamedObject(t *testing.T) {
|
||||
func TestDeleteObject(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
@@ -127,10 +127,10 @@ func TestDeleteObject(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteObjectNotFound(t *testing.T) {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
@@ -157,10 +157,10 @@ func TestDeleteObjectNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteObjectIgnoreNotFound(t *testing.T) {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
@@ -189,7 +189,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
|
||||
func TestDeleteAllNotFound(t *testing.T) {
|
||||
_, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
|
||||
// Add an item to the list which will result in a 404 on delete
|
||||
svc.Items = append(svc.Items, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
@@ -197,7 +197,7 @@ func TestDeleteAllNotFound(t *testing.T) {
|
||||
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/services" && m == "GET":
|
||||
@@ -231,7 +231,7 @@ func TestDeleteAllNotFound(t *testing.T) {
|
||||
func TestDeleteAllIgnoreNotFound(t *testing.T) {
|
||||
_, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
|
||||
// Add an item to the list which will result in a 404 on delete
|
||||
svc.Items = append(svc.Items, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
@@ -239,7 +239,7 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
|
||||
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/services" && m == "GET":
|
||||
@@ -271,10 +271,10 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
|
||||
func TestDeleteMultipleObject(t *testing.T) {
|
||||
_, svc, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
@@ -305,10 +305,10 @@ func TestDeleteMultipleObject(t *testing.T) {
|
||||
func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
|
||||
_, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
@@ -342,10 +342,10 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
|
||||
|
||||
func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
|
||||
_, svc, rc := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/baz" && m == "DELETE":
|
||||
@@ -378,10 +378,10 @@ func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
|
||||
func TestDeleteDirectory(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case strings.HasPrefix(p, "/namespaces/test/replicationcontrollers/") && m == "DELETE":
|
||||
@@ -409,10 +409,10 @@ func TestDeleteDirectory(t *testing.T) {
|
||||
func TestDeleteMultipleSelector(t *testing.T) {
|
||||
pods, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/pods" && m == "GET":
|
||||
@@ -474,7 +474,7 @@ func TestResourceErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
for k, testCase := range testCases {
|
||||
f, tf, _ := NewAPIFactory()
|
||||
f, tf, _, _ := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
|
||||
|
@@ -28,11 +28,11 @@ import (
|
||||
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
|
||||
func TestDescribeUnknownSchemaObject(t *testing.T) {
|
||||
d := &testDescriber{Output: "test output"}
|
||||
f, tf, codec := NewTestFactory()
|
||||
f, tf, codec, ns := NewTestFactory()
|
||||
tf.Describer = d
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &internalType{Name: "foo"})},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &internalType{Name: "foo"})},
|
||||
}
|
||||
tf.Namespace = "non-default"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -51,11 +51,11 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
|
||||
|
||||
func TestDescribeObject(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
d := &testDescriber{Output: "test output"}
|
||||
tf.Describer = d
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "GET":
|
||||
@@ -84,12 +84,12 @@ func TestDescribeObject(t *testing.T) {
|
||||
|
||||
func TestDescribeListObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
d := &testDescriber{Output: "test output"}
|
||||
tf.Describer = d
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
|
||||
tf.Namespace = "test"
|
||||
@@ -103,12 +103,12 @@ func TestDescribeListObjects(t *testing.T) {
|
||||
|
||||
func TestDescribeObjectShowEvents(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
d := &testDescriber{Output: "test output"}
|
||||
tf.Describer = d
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
|
||||
tf.Namespace = "test"
|
||||
@@ -123,12 +123,12 @@ func TestDescribeObjectShowEvents(t *testing.T) {
|
||||
|
||||
func TestDescribeObjectSkipEvents(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
d := &testDescriber{Output: "test output"}
|
||||
tf.Describer = d
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
|
||||
tf.Namespace = "test"
|
||||
|
@@ -132,11 +132,11 @@ func TestCordon(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
new_node := &api.Node{}
|
||||
updated := false
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
m := &MyReq{req}
|
||||
switch {
|
||||
@@ -456,10 +456,10 @@ func TestDrain(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
new_node := &api.Node{}
|
||||
deleted := false
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
m := &MyReq{req}
|
||||
switch {
|
||||
@@ -561,7 +561,7 @@ func refJson(t *testing.T, o runtime.Object) string {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
_, _, codec := NewAPIFactory()
|
||||
_, _, codec, _ := NewAPIFactory()
|
||||
json, err := runtime.Encode(codec, &api.SerializedReference{Reference: *ref})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
|
@@ -124,10 +124,10 @@ func TestPodAndContainer(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, _, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{}
|
||||
@@ -180,9 +180,9 @@ func TestExec(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
|
@@ -366,10 +366,10 @@ func TestRunExposeService(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &kubectl.JSONPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.calls[m] && m == "GET":
|
||||
|
@@ -35,6 +35,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/fake"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer/json"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer/streaming"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
@@ -117,11 +118,11 @@ func testComponentStatusData() *api.ComponentStatusList {
|
||||
|
||||
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
|
||||
func TestGetUnknownSchemaObject(t *testing.T) {
|
||||
f, tf, codec := NewTestFactory()
|
||||
f, tf, codec, ns := NewTestFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &internalType{Name: "foo"})},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &internalType{Name: "foo"})},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
|
||||
@@ -180,17 +181,21 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
|
||||
}
|
||||
for k, test := range testCases {
|
||||
apiCodec := testapi.Default.Codec()
|
||||
apiNegotiatedSerializer := testapi.Default.NegotiatedSerializer()
|
||||
regularClient := &fake.RESTClient{
|
||||
Codec: apiCodec,
|
||||
NegotiatedSerializer: apiNegotiatedSerializer,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
return &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(apiCodec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}})}, nil
|
||||
}),
|
||||
}
|
||||
|
||||
f, tf, codec := NewMixedFactory(regularClient)
|
||||
negotiatedSerializer := serializer.NegotiatedSerializerWrapper(
|
||||
runtime.SerializerInfo{Serializer: codec},
|
||||
runtime.StreamSerializerInfo{})
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: negotiatedSerializer,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
return &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &internalType{Name: "foo"})}, nil
|
||||
}),
|
||||
@@ -228,14 +233,15 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
|
||||
|
||||
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
|
||||
func TestGetSchemaObject(t *testing.T) {
|
||||
f, tf, _ := NewTestFactory()
|
||||
f, tf, _, _ := NewTestFactory()
|
||||
tf.Mapper = testapi.Default.RESTMapper()
|
||||
tf.Typer = api.Scheme
|
||||
codec := testapi.Default.Codec()
|
||||
ns := testapi.Default.NegotiatedSerializer()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}})},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}})},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: "v1"}}}
|
||||
@@ -252,11 +258,11 @@ func TestGetSchemaObject(t *testing.T) {
|
||||
func TestGetObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -296,11 +302,11 @@ func TestGetSortedObjects(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: "v1"}}}
|
||||
@@ -328,11 +334,11 @@ func TestGetSortedObjects(t *testing.T) {
|
||||
func TestGetObjectsIdentifiedByFile(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -355,11 +361,11 @@ func TestGetObjectsIdentifiedByFile(t *testing.T) {
|
||||
func TestGetListObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -398,11 +404,11 @@ func extractResourceList(objs []runtime.Object) ([]runtime.Object, error) {
|
||||
func TestGetAllListObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, pods)},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -428,11 +434,11 @@ func TestGetAllListObjects(t *testing.T) {
|
||||
func TestGetListComponentStatus(t *testing.T) {
|
||||
statuses := testComponentStatusData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, statuses)},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, statuses)},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -457,10 +463,10 @@ func TestGetListComponentStatus(t *testing.T) {
|
||||
func TestGetMultipleTypeObjects(t *testing.T) {
|
||||
pods, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/namespaces/test/pods":
|
||||
@@ -496,10 +502,10 @@ func TestGetMultipleTypeObjects(t *testing.T) {
|
||||
func TestGetMultipleTypeObjectsAsList(t *testing.T) {
|
||||
pods, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/namespaces/test/pods":
|
||||
@@ -556,10 +562,10 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
|
||||
func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
|
||||
pods, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||
@@ -608,10 +614,10 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/nodes/foo":
|
||||
@@ -645,11 +651,11 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
|
||||
func TestGetByNameForcesFlag(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
NegotiatedSerializer: ns,
|
||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])},
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
@@ -705,10 +711,10 @@ func watchTestData() ([]api.Pod, []watch.Event) {
|
||||
func TestWatchSelector(t *testing.T) {
|
||||
pods, events := watchTestData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||
@@ -747,10 +753,10 @@ func TestWatchSelector(t *testing.T) {
|
||||
func TestWatchResource(t *testing.T) {
|
||||
pods, events := watchTestData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/namespaces/test/pods/foo":
|
||||
@@ -785,10 +791,10 @@ func TestWatchResource(t *testing.T) {
|
||||
func TestWatchResourceIdentifiedByFile(t *testing.T) {
|
||||
pods, events := watchTestData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/namespaces/test/replicationcontrollers/cassandra":
|
||||
@@ -824,10 +830,10 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
|
||||
func TestWatchOnlyResource(t *testing.T) {
|
||||
pods, events := watchTestData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.URL.Path {
|
||||
case "/namespaces/test/pods/foo":
|
||||
|
@@ -310,7 +310,7 @@ func TestLabelErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
for k, testCase := range testCases {
|
||||
f, tf, _ := NewAPIFactory()
|
||||
f, tf, _, _ := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
|
||||
@@ -338,9 +338,9 @@ func TestLabelErrors(t *testing.T) {
|
||||
|
||||
func TestLabelForResourceFromFile(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.Method {
|
||||
case "GET":
|
||||
@@ -385,9 +385,9 @@ func TestLabelForResourceFromFile(t *testing.T) {
|
||||
|
||||
func TestLabelMultipleObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch req.Method {
|
||||
case "GET":
|
||||
|
@@ -47,9 +47,9 @@ func TestLog(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
logContent := "test log content"
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
@@ -95,7 +95,7 @@ func testPod() *api.Pod {
|
||||
}
|
||||
|
||||
func TestValidateLogFlags(t *testing.T) {
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@@ -27,10 +27,10 @@ import (
|
||||
func TestPatchObject(t *testing.T) {
|
||||
_, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/services/frontend" && (m == "PATCH" || m == "GET"):
|
||||
@@ -59,10 +59,10 @@ func TestPatchObject(t *testing.T) {
|
||||
func TestPatchObjectFromFile(t *testing.T) {
|
||||
_, svc, _ := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/services/frontend" && (m == "PATCH" || m == "GET"):
|
||||
|
@@ -68,9 +68,9 @@ func TestPortForward(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
@@ -138,9 +138,9 @@ func TestPortForwardWithPFlag(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == test.podPath && m == "GET":
|
||||
|
@@ -28,10 +28,10 @@ import (
|
||||
func TestReplaceObject(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && (m == "GET" || m == "PUT" || m == "DELETE"):
|
||||
@@ -71,10 +71,10 @@ func TestReplaceObject(t *testing.T) {
|
||||
func TestReplaceMultipleObject(t *testing.T) {
|
||||
_, svc, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && (m == "GET" || m == "PUT" || m == "DELETE"):
|
||||
@@ -118,10 +118,10 @@ func TestReplaceMultipleObject(t *testing.T) {
|
||||
func TestReplaceDirectory(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case strings.HasPrefix(p, "/namespaces/test/replicationcontrollers/") && (m == "GET" || m == "PUT" || m == "DELETE"):
|
||||
@@ -161,10 +161,10 @@ func TestReplaceDirectory(t *testing.T) {
|
||||
func TestForceReplaceObjectNotFound(t *testing.T) {
|
||||
_, _, rc := testData()
|
||||
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == "/namespaces/test/replicationcontrollers/redis-master" && m == "DELETE":
|
||||
|
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func TestValidateArgs(t *testing.T) {
|
||||
f, _, _ := NewAPIFactory()
|
||||
f, _, _, _ := NewAPIFactory()
|
||||
|
||||
tests := []struct {
|
||||
flags map[string]string
|
||||
|
@@ -149,9 +149,9 @@ func TestRunArgsFollowDashRules(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
return &http.Response{StatusCode: 201, Header: defaultHeader(), Body: objBody(codec, &rc.Items[0])}, nil
|
||||
}),
|
||||
@@ -264,10 +264,10 @@ func TestGenerateService(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
sawPOST := false
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case test.expectPOST && m == "POST" && p == "/namespaces/namespace/services":
|
||||
|
@@ -232,10 +232,10 @@ func TestTaint(t *testing.T) {
|
||||
|
||||
new_node := &api.Node{}
|
||||
tainted := false
|
||||
f, tf, codec := NewAPIFactory()
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
|
||||
tf.Client = &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: ns,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
m := &MyReq{req}
|
||||
switch {
|
||||
|
@@ -380,7 +380,6 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
||||
gv := gvk.GroupVersion()
|
||||
cfg.GroupVersion = &gv
|
||||
cfg.APIPath = "/apis"
|
||||
cfg.Codec = thirdpartyresourcedata.NewCodec(c.ExtensionsClient.RESTClient.Codec(), gvk)
|
||||
cfg.NegotiatedSerializer = thirdpartyresourcedata.NewNegotiatedSerializer(api.Codecs, gvk.Kind, gv, gv)
|
||||
return restclient.RESTClientFor(cfg)
|
||||
}
|
||||
|
@@ -263,7 +263,7 @@ func TestRefetchSchemaWhenValidationFails(t *testing.T) {
|
||||
requests := map[string]int{}
|
||||
|
||||
c := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case strings.HasPrefix(p, "/swaggerapi") && m == "GET":
|
||||
@@ -320,7 +320,7 @@ func TestValidateCachesSchema(t *testing.T) {
|
||||
requests := map[string]int{}
|
||||
|
||||
c := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case strings.HasPrefix(p, "/swaggerapi") && m == "GET":
|
||||
|
@@ -69,7 +69,7 @@ func fakeClient() ClientMapper {
|
||||
func fakeClientWith(testName string, t *testing.T, data map[string]string) ClientMapper {
|
||||
return ClientMapperFunc(func(*meta.RESTMapping) (RESTClient, error) {
|
||||
return &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
p := req.URL.Path
|
||||
q := req.URL.RawQuery
|
||||
|
@@ -103,9 +103,9 @@ func TestHelperDelete(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
client := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
}
|
||||
modifier := &Helper{
|
||||
RESTClient: client,
|
||||
@@ -193,9 +193,9 @@ func TestHelperCreate(t *testing.T) {
|
||||
}
|
||||
for i, test := range tests {
|
||||
client := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
}
|
||||
modifier := &Helper{
|
||||
RESTClient: client,
|
||||
@@ -273,9 +273,9 @@ func TestHelperGet(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
client := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
}
|
||||
modifier := &Helper{
|
||||
RESTClient: client,
|
||||
@@ -346,9 +346,9 @@ func TestHelperList(t *testing.T) {
|
||||
}
|
||||
for _, test := range tests {
|
||||
client := &fake.RESTClient{
|
||||
Codec: testapi.Default.Codec(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
}
|
||||
modifier := &Helper{
|
||||
RESTClient: client,
|
||||
@@ -479,10 +479,10 @@ func TestHelperReplace(t *testing.T) {
|
||||
}
|
||||
for i, test := range tests {
|
||||
client := &fake.RESTClient{
|
||||
Client: test.HTTPClient,
|
||||
Codec: testapi.Default.Codec(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
Client: test.HTTPClient,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Resp: test.Resp,
|
||||
Err: test.HttpErr,
|
||||
}
|
||||
modifier := &Helper{
|
||||
RESTClient: client,
|
||||
|
@@ -1413,7 +1413,7 @@ func TestUpdateRcWithRetries(t *testing.T) {
|
||||
{StatusCode: 200, Header: header, Body: objBody(codec, rc)},
|
||||
}
|
||||
fakeClient := &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == testapi.Default.ResourcePath("replicationcontrollers", "default", "rc") && m == "PUT":
|
||||
@@ -1504,7 +1504,7 @@ func TestAddDeploymentHash(t *testing.T) {
|
||||
seen := sets.String{}
|
||||
updatedRc := false
|
||||
fakeClient := &fake.RESTClient{
|
||||
Codec: codec,
|
||||
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
header := http.Header{}
|
||||
header.Set("Content-Type", runtime.ContentTypeJSON)
|
||||
|
Reference in New Issue
Block a user