simplify kubectl testing factory

This commit is contained in:
David Eads
2018-02-22 09:52:10 -05:00
parent 82eeda0885
commit 6047ead2e5
50 changed files with 508 additions and 781 deletions

View File

@@ -130,7 +130,7 @@ func TestPodAndContainer(t *testing.T) {
},
}
for _, test := range tests {
f, tf := cmdtesting.NewAPIFactory()
tf := cmdtesting.NewTestFactory()
ns := legacyscheme.Codecs
tf.Client = &fake.RESTClient{
@@ -138,12 +138,12 @@ func TestPodAndContainer(t *testing.T) {
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
}
tf.Namespace = "test"
tf.ClientConfig = defaultClientConfig()
tf.ClientConfigVal = defaultClientConfig()
cmd := &cobra.Command{}
options := test.p
options.Err = bytes.NewBuffer([]byte{})
err := options.Complete(f, cmd, test.args, test.argsLenAtDash)
err := options.Complete(tf, cmd, test.args, test.argsLenAtDash)
if test.expectError && err == nil {
t.Errorf("%s: unexpected non-error", test.name)
}
@@ -187,7 +187,7 @@ func TestExec(t *testing.T) {
},
}
for _, test := range tests {
f, tf := cmdtesting.NewAPIFactory()
tf := cmdtesting.NewTestFactory()
codec := legacyscheme.Codecs.LegacyCodec(scheme.Versions...)
ns := legacyscheme.Codecs
@@ -206,7 +206,7 @@ func TestExec(t *testing.T) {
}),
}
tf.Namespace = "test"
tf.ClientConfig = defaultClientConfig()
tf.ClientConfigVal = defaultClientConfig()
bufOut := bytes.NewBuffer([]byte{})
bufErr := bytes.NewBuffer([]byte{})
bufIn := bytes.NewBuffer([]byte{})
@@ -226,7 +226,7 @@ func TestExec(t *testing.T) {
}
cmd := &cobra.Command{}
args := []string{"test", "command"}
if err := params.Complete(f, cmd, args, -1); err != nil {
if err := params.Complete(tf, cmd, args, -1); err != nil {
t.Fatal(err)
}
err := params.Run()