mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
remove unnecessary factory delegation for RESTClientGetter method
This commit is contained in:
committed by
Maciej Szulik
parent
4da73a5f3d
commit
c85e69aeb9
@@ -68,7 +68,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
|
||||
|
||||
for i, input := range inputs {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
tf := cmdtesting.NewTestFactory()
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
|
||||
tf.Client = &fake.RESTClient{
|
||||
@@ -81,7 +81,6 @@ func TestSetServiceAccountLocal(t *testing.T) {
|
||||
|
||||
outputFormat := "yaml"
|
||||
|
||||
tf.Namespace = "test"
|
||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
cmd := NewCmdServiceAccount(tf, streams)
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
@@ -105,7 +104,7 @@ func TestSetServiceAccountLocal(t *testing.T) {
|
||||
|
||||
func TestSetServiceAccountMultiLocal(t *testing.T) {
|
||||
testapi.Default = testapi.Groups[""]
|
||||
tf := cmdtesting.NewTestFactory()
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
|
||||
tf.Client = &fake.RESTClient{
|
||||
@@ -116,7 +115,6 @@ func TestSetServiceAccountMultiLocal(t *testing.T) {
|
||||
return nil, nil
|
||||
}),
|
||||
}
|
||||
tf.Namespace = "test"
|
||||
tf.ClientConfigVal = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Version: ""}}}
|
||||
|
||||
outputFormat := "name"
|
||||
@@ -326,15 +324,14 @@ func TestSetServiceAccountRemote(t *testing.T) {
|
||||
t.Run(input.apiPrefix, func(t *testing.T) {
|
||||
groupVersion := schema.GroupVersion{Group: input.apiGroup, Version: input.apiVersion}
|
||||
testapi.Default = testapi.Groups[input.testAPIGroup]
|
||||
tf := cmdtesting.NewTestFactory()
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
|
||||
tf.Namespace = "test"
|
||||
tf.Client = &fake.RESTClient{
|
||||
GroupVersion: groupVersion,
|
||||
NegotiatedSerializer: serializer.DirectCodecFactory{CodecFactory: scheme.Codecs},
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
resourcePath := testapi.Default.ResourcePath(input.args[0]+"s", tf.Namespace, input.args[1])
|
||||
resourcePath := testapi.Default.ResourcePath(input.args[0]+"s", "test", input.args[1])
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == resourcePath && m == http.MethodGet:
|
||||
return &http.Response{StatusCode: http.StatusOK, Header: defaultHeader(), Body: objBody(input.object)}, nil
|
||||
@@ -387,7 +384,7 @@ func TestServiceAccountValidation(t *testing.T) {
|
||||
}
|
||||
for _, input := range inputs {
|
||||
t.Run(input.name, func(t *testing.T) {
|
||||
tf := cmdtesting.NewTestFactory()
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
|
||||
tf.Client = &fake.RESTClient{
|
||||
@@ -400,7 +397,6 @@ func TestServiceAccountValidation(t *testing.T) {
|
||||
|
||||
outputFormat := ""
|
||||
|
||||
tf.Namespace = "test"
|
||||
streams := genericclioptions.NewTestIOStreamsDiscard()
|
||||
cmd := NewCmdServiceAccount(tf, streams)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user