mirror of https://github.com/k3s-io/k3s
Merge pull request #57081 from liggitt/content-type-tests
Automatic merge from submit-queue (batch tested with PRs 56828, 55184, 56849, 57081, 56654). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add tests for accept content-type fallbackpull/6/head
commit
03a656f234
|
@ -2026,11 +2026,29 @@ func TestGetPartialObjectMetadata(t *testing.T) {
|
|||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadata;v=v1;g=meta.k8s.io",
|
||||
statusCode: http.StatusNotAcceptable,
|
||||
},
|
||||
{
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadata;v=v1;g=meta.k8s.io, application/json",
|
||||
expectKind: schema.GroupVersionKind{Kind: "Simple", Group: testGroupVersion.Group, Version: testGroupVersion.Version},
|
||||
},
|
||||
{
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadata;v=v1alpha1;g=meta.k8s.io, application/json",
|
||||
expectKind: schema.GroupVersionKind{Kind: "PartialObjectMetadata", Group: "meta.k8s.io", Version: "v1alpha1"},
|
||||
},
|
||||
{
|
||||
list: true,
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadata;v=v1alpha1;g=meta.k8s.io",
|
||||
statusCode: http.StatusNotAcceptable,
|
||||
},
|
||||
{
|
||||
list: true,
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadata;v=v1;g=meta.k8s.io, application/json",
|
||||
expectKind: schema.GroupVersionKind{Kind: "SimpleList", Group: testGroupVersion.Group, Version: testGroupVersion.Version},
|
||||
},
|
||||
{
|
||||
list: true,
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadataList;v=v1alpha1;g=meta.k8s.io, application/json",
|
||||
expectKind: schema.GroupVersionKind{Kind: "PartialObjectMetadataList", Group: "meta.k8s.io", Version: "v1alpha1"},
|
||||
},
|
||||
{
|
||||
accept: runtime.ContentTypeJSON + ";as=PartialObjectMetadataList;v=v1alpha1;g=meta.k8s.io",
|
||||
statusCode: http.StatusNotAcceptable,
|
||||
|
@ -2096,12 +2114,22 @@ func TestGetPartialObjectMetadata(t *testing.T) {
|
|||
t.Errorf("%d: invalid status: %#v\n%s", i, resp, bodyOrDie(resp))
|
||||
continue
|
||||
}
|
||||
itemOut, body, err := extractBodyObject(resp, metainternalversion.Codecs.LegacyCodec(metav1alpha1.SchemeGroupVersion))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(test.expected, itemOut) {
|
||||
t.Errorf("%d: did not match: %s", i, diff.ObjectReflectDiff(test.expected, itemOut))
|
||||
body := ""
|
||||
if test.expected != nil {
|
||||
itemOut, d, err := extractBodyObject(resp, metainternalversion.Codecs.LegacyCodec(metav1alpha1.SchemeGroupVersion))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(test.expected, itemOut) {
|
||||
t.Errorf("%d: did not match: %s", i, diff.ObjectReflectDiff(test.expected, itemOut))
|
||||
}
|
||||
body = d
|
||||
} else {
|
||||
d, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body = string(d)
|
||||
}
|
||||
obj := &unstructured.Unstructured{}
|
||||
if err := json.Unmarshal([]byte(body), obj); err != nil {
|
||||
|
|
Loading…
Reference in New Issue