Fix tests that assume core clients use JSON

Signed-off-by: Monis Khan <mok@microsoft.com>
This commit is contained in:
Monis Khan 2024-08-19 10:38:16 -04:00
parent 032e7f1556
commit 6595fa4026
No known key found for this signature in database
4 changed files with 11 additions and 7 deletions

View File

@ -73,12 +73,14 @@ func Test_buildClientCertificateManager(t *testing.T) {
defer s.Close()
config1 := &restclient.Config{
UserAgent: "FirstClient",
Host: s.URL,
UserAgent: "FirstClient",
Host: s.URL,
ContentConfig: restclient.ContentConfig{ContentType: runtime.ContentTypeJSON},
}
config2 := &restclient.Config{
UserAgent: "SecondClient",
Host: s.URL,
UserAgent: "SecondClient",
Host: s.URL,
ContentConfig: restclient.ContentConfig{ContentType: runtime.ContentTypeJSON},
}
nodeName := types.NodeName("test")

View File

@ -375,7 +375,7 @@ func TestCreatePodsWithGenerateName(t *testing.T) {
}
testServer := httptest.NewServer(&fakeHandler)
defer testServer.Close()
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}, ContentType: runtime.ContentTypeJSON}})
podControl := RealPodControl{
KubeClient: clientset,

View File

@ -27,6 +27,7 @@ import (
"time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
@ -225,7 +226,7 @@ type endpointController struct {
}
func newController(ctx context.Context, url string, batchPeriod time.Duration) *endpointController {
client := clientset.NewForConfigOrDie(&restclient.Config{Host: url, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
client := clientset.NewForConfigOrDie(&restclient.Config{Host: url, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}, ContentType: runtime.ContentTypeJSON}})
informerFactory := informers.NewSharedInformerFactory(client, controllerpkg.NoResyncPeriodFunc())
endpoints := NewEndpointController(ctx, informerFactory.Core().V1().Pods(), informerFactory.Core().V1().Services(),
informerFactory.Core().V1().Endpoints(), client, batchPeriod)

View File

@ -161,7 +161,7 @@ func TestRunAccessCheck(t *testing.T) {
test.serverErr
}),
}
tf.ClientConfigVal = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}}
tf.ClientConfigVal = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}, ContentType: runtime.ContentTypeJSON}}
if err := test.o.Complete(tf, test.args); err != nil {
t.Errorf("%s: %v", test.name, err)
@ -196,6 +196,7 @@ func TestRunAccessList(t *testing.T) {
" [/version] [] [get]\n"
tf := cmdtesting.NewTestFactory().WithNamespace("test")
tf.ClientConfigVal.ContentType = runtime.ContentTypeJSON
defer tf.Cleanup()
ns := scheme.Codecs.WithoutConversion()