mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-28 16:07:29 +00:00
Adjust openapi test to avoid mutation on write
Kubernetes-commit: ee816114b7ae044f23b4776fdf0c3f04e2ce13e3
This commit is contained in:
parent
d847b4c964
commit
cd3db5b5a1
@ -402,7 +402,8 @@ func TestGetServerResources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnedOpenAPI = openapi_v2.Document{
|
func returnedOpenAPI() *openapi_v2.Document {
|
||||||
|
return &openapi_v2.Document{
|
||||||
Definitions: &openapi_v2.Definitions{
|
Definitions: &openapi_v2.Definitions{
|
||||||
AdditionalProperties: []*openapi_v2.NamedSchema{
|
AdditionalProperties: []*openapi_v2.NamedSchema{
|
||||||
{
|
{
|
||||||
@ -450,6 +451,7 @@ var returnedOpenAPI = openapi_v2.Document{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func openapiSchemaDeprecatedFakeServer(status int) (*httptest.Server, error) {
|
func openapiSchemaDeprecatedFakeServer(status int) (*httptest.Server, error) {
|
||||||
@ -469,7 +471,7 @@ func openapiSchemaDeprecatedFakeServer(status int) (*httptest.Server, error) {
|
|||||||
|
|
||||||
mime.AddExtensionType(".pb-v1", "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf")
|
mime.AddExtensionType(".pb-v1", "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf")
|
||||||
|
|
||||||
output, err := proto.Marshal(&returnedOpenAPI)
|
output, err := proto.Marshal(returnedOpenAPI())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sErr = err
|
sErr = err
|
||||||
return
|
return
|
||||||
@ -496,7 +498,7 @@ func openapiSchemaFakeServer() (*httptest.Server, error) {
|
|||||||
|
|
||||||
mime.AddExtensionType(".pb-v1", "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf")
|
mime.AddExtensionType(".pb-v1", "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf")
|
||||||
|
|
||||||
output, err := proto.Marshal(&returnedOpenAPI)
|
output, err := proto.Marshal(returnedOpenAPI())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sErr = err
|
sErr = err
|
||||||
return
|
return
|
||||||
@ -519,7 +521,7 @@ func TestGetOpenAPISchema(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error getting openapi: %v", err)
|
t.Fatalf("unexpected error getting openapi: %v", err)
|
||||||
}
|
}
|
||||||
if e, a := returnedOpenAPI, *got; !reflect.DeepEqual(e, a) {
|
if e, a := returnedOpenAPI(), got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("expected %v, got %v", e, a)
|
t.Errorf("expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -536,7 +538,7 @@ func TestGetOpenAPISchemaForbiddenFallback(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error getting openapi: %v", err)
|
t.Fatalf("unexpected error getting openapi: %v", err)
|
||||||
}
|
}
|
||||||
if e, a := returnedOpenAPI, *got; !reflect.DeepEqual(e, a) {
|
if e, a := returnedOpenAPI(), got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("expected %v, got %v", e, a)
|
t.Errorf("expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,7 +555,7 @@ func TestGetOpenAPISchemaNotFoundFallback(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error getting openapi: %v", err)
|
t.Fatalf("unexpected error getting openapi: %v", err)
|
||||||
}
|
}
|
||||||
if e, a := returnedOpenAPI, *got; !reflect.DeepEqual(e, a) {
|
if e, a := returnedOpenAPI(), got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("expected %v, got %v", e, a)
|
t.Errorf("expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -570,7 +572,7 @@ func TestGetOpenAPISchemaNotAcceptableFallback(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error getting openapi: %v", err)
|
t.Fatalf("unexpected error getting openapi: %v", err)
|
||||||
}
|
}
|
||||||
if e, a := returnedOpenAPI, *got; !reflect.DeepEqual(e, a) {
|
if e, a := returnedOpenAPI(), got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("expected %v, got %v", e, a)
|
t.Errorf("expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user