mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
![Dana Hoffman](/assets/img/avatar_default.png)
* Revert "Merge pull request #1434 from terraform-providers/paddy_revert_beta" This reverts commit118cd71201
, reversing changes made tod59fcbbc59
. * add ConvertSelfLinkToV1 calls to places where beta links are stored
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package google
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestSetOmittedFields(t *testing.T) {
|
|
type Inner struct {
|
|
InnerNotOmitted string `json:"notOmitted"`
|
|
InnerOmitted []string `json:"-"`
|
|
}
|
|
type InputOuter struct {
|
|
NotOmitted string `json:"notOmitted"`
|
|
Omitted []string `json:"-"`
|
|
Struct Inner
|
|
Pointer *Inner
|
|
StructSlice []Inner
|
|
PointerSlice []*Inner
|
|
Unset *Inner
|
|
OnlyInInputType *Inner
|
|
}
|
|
type OutputOuter struct {
|
|
NotOmitted string `json:"notOmitted"`
|
|
Omitted []string `json:"-"`
|
|
Struct Inner
|
|
Pointer *Inner
|
|
StructSlice []Inner
|
|
PointerSlice []*Inner
|
|
Unset *Inner
|
|
OnlyInOutputType *Inner
|
|
}
|
|
|
|
input := &InputOuter{
|
|
NotOmitted: "foo",
|
|
Omitted: []string{"foo"},
|
|
Struct: Inner{
|
|
InnerNotOmitted: "foo",
|
|
InnerOmitted: []string{"foo"},
|
|
},
|
|
Pointer: &Inner{
|
|
InnerNotOmitted: "foo",
|
|
InnerOmitted: []string{"foo"},
|
|
},
|
|
StructSlice: []Inner{
|
|
{
|
|
InnerNotOmitted: "foo",
|
|
InnerOmitted: []string{"foo"},
|
|
}, {
|
|
InnerNotOmitted: "bar",
|
|
InnerOmitted: []string{"bar"},
|
|
},
|
|
},
|
|
PointerSlice: []*Inner{
|
|
{
|
|
InnerNotOmitted: "foo",
|
|
InnerOmitted: []string{"foo"},
|
|
}, {
|
|
InnerNotOmitted: "bar",
|
|
InnerOmitted: []string{"bar"},
|
|
},
|
|
},
|
|
OnlyInInputType: &Inner{
|
|
InnerNotOmitted: "foo",
|
|
InnerOmitted: []string{"foo"},
|
|
},
|
|
}
|
|
output := &OutputOuter{}
|
|
Convert(input, output)
|
|
if input.NotOmitted != output.NotOmitted ||
|
|
!reflect.DeepEqual(input.Omitted, output.Omitted) ||
|
|
!reflect.DeepEqual(input.Struct, output.Struct) ||
|
|
!reflect.DeepEqual(input.Pointer, output.Pointer) ||
|
|
!reflect.DeepEqual(input.StructSlice, output.StructSlice) ||
|
|
!reflect.DeepEqual(input.PointerSlice, output.PointerSlice) ||
|
|
!(input.Unset == nil && output.Unset == nil) {
|
|
t.Errorf("Structs were not equivalent after conversion:\nInput:%#v\nOutput: %#v", input, output)
|
|
}
|
|
}
|