Skip to content

Commit

Permalink
Add new tests for deepcopy
Browse files Browse the repository at this point in the history
Add new tests convering types related to changes made under
kubernetes#46
  • Loading branch information
spzala committed May 23, 2017
1 parent 1914576 commit aa0cba9
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/deepcopy-gen/output_tests/emptyinterface/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package

// This is a test package.
package emptyinterface

type Ttest struct {
Interface interface{}
}
52 changes: 52 additions & 0 deletions examples/deepcopy-gen/output_tests/emptyinterface/zz_generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// +build !ignore_autogenerated

/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This file was autogenerated by deepcopy-gen. Do not edit it manually!

package emptyinterface

import (
conversion "k8s.io/apimachinery/pkg/conversion"
reflect "reflect"
)

// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
return []conversion.GeneratedDeepCopyFunc{
{Fn: DeepCopy_emptyinterface_Ttest, InType: reflect.TypeOf(&Ttest{})},
}
}

// DeepCopy_emptyinterface_Ttest is an autogenerated deepcopy function.
func DeepCopy_emptyinterface_Ttest(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Ttest)
out := out.(*Ttest)
*out = *in
// in.Interface is kind 'Interface'
if in.Interface != nil {
newVal, err := c.DeepCopy(&in.Interface)
if err != nil {
return err
}
out.Interface = *newVal.(*interface{})

}
return nil
}
}
28 changes: 28 additions & 0 deletions examples/deepcopy-gen/output_tests/interfaces/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package

// This is a test package.
package interfaces

type Inter interface {
function() float64
}

type Ttest struct {
i []Inter
}
55 changes: 55 additions & 0 deletions examples/deepcopy-gen/output_tests/interfaces/zz_generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// +build !ignore_autogenerated

/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This file was autogenerated by deepcopy-gen. Do not edit it manually!

package interfaces

import (
conversion "k8s.io/apimachinery/pkg/conversion"
reflect "reflect"
)

// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
return []conversion.GeneratedDeepCopyFunc{
{Fn: DeepCopy_interfaces_Ttest, InType: reflect.TypeOf(&Ttest{})},
}
}

// DeepCopy_interfaces_Ttest is an autogenerated deepcopy function.
func DeepCopy_interfaces_Ttest(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Ttest)
out := out.(*Ttest)
*out = *in
if in.i != nil {
in, out := &in.i, &out.i
*out = make([]Inter, len(*in))
for i := range *in {
newVal, err := c.DeepCopy(&(*in)[i])
if err != nil {
return err
}
(*out)[i] = *newVal.(*Inter)

}
}
return nil
}
}
24 changes: 24 additions & 0 deletions examples/deepcopy-gen/output_tests/pointer/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package

// This is a test package.
package pointer

type Ttest struct {
Types map[string]*Ttest
}
55 changes: 55 additions & 0 deletions examples/deepcopy-gen/output_tests/pointer/zz_generated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// +build !ignore_autogenerated

/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This file was autogenerated by deepcopy-gen. Do not edit it manually!

package pointer

import (
conversion "k8s.io/apimachinery/pkg/conversion"
reflect "reflect"
)

// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
return []conversion.GeneratedDeepCopyFunc{
{Fn: DeepCopy_pointer_Ttest, InType: reflect.TypeOf(&Ttest{})},
}
}

// DeepCopy_pointer_Ttest is an autogenerated deepcopy function.
func DeepCopy_pointer_Ttest(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Ttest)
out := out.(*Ttest)
*out = *in
if in.Types != nil {
in, out := &in.Types, &out.Types
*out = make(map[string]*Ttest)
for key, val := range *in {
newVal, err := c.DeepCopy(&val)
if err != nil {
return err
}
(*out)[key] = *newVal.(**Ttest)

}
}
return nil
}
}

0 comments on commit aa0cba9

Please # to comment.