mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
simplify kubectl testing factory
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user