Fix randomization so it ignores pkeys

This commit is contained in:
Aaron L 2016-08-26 22:53:36 -07:00
parent 9db43ae3ad
commit 204ca1291d

View file

@ -1,5 +1,6 @@
{{- define "relationship_to_one_setops_test_helper" -}}
{{- $varNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}}
{{- $varNameSingular := .ForeignKey.Table | singular | camelCase -}}
{{- $foreignVarNameSingular := .ForeignKey.ForeignTable | singular | camelCase -}}
func test{{.LocalTable.NameGo}}ToOneSetOp{{.ForeignTable.NameGo}}_{{.Function.Name}}(t *testing.T) {
var err error
@ -10,13 +11,13 @@ func test{{.LocalTable.NameGo}}ToOneSetOp{{.ForeignTable.NameGo}}_{{.Function.Na
var b, c {{.ForeignTable.NameGo}}
seed := randomize.NewSeed()
if err = randomize.Struct(seed, &a, {{.ForeignKey.Table | singular | camelCase}}DBTypes, false); err != nil {
if err = randomize.Struct(seed, &a, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
t.Fatal(err)
}
if err = randomize.Struct(seed, &b, {{$varNameSingular}}DBTypes, false); err != nil {
if err = randomize.Struct(seed, &b, {{$foreignVarNameSingular}}DBTypes, false, {{$foreignVarNameSingular}}PrimaryKeyColumns...); err != nil {
t.Fatal(err)
}
if err = randomize.Struct(seed, &c, {{$varNameSingular}}DBTypes, false); err != nil {
if err = randomize.Struct(seed, &c, {{$foreignVarNameSingular}}DBTypes, false, {{$foreignVarNameSingular}}PrimaryKeyColumns...); err != nil {
t.Fatal(err)
}