From c00ebe19110044f1c0ba0965bbca9555cf5f0e46 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Wed, 14 Jun 2017 21:14:54 -0700 Subject: [PATCH] Correct nullability for tests in to_one - Use the nullability of the fkey column in question to determine nullability for the entire struct to make things easy, otherwise we'd have to pluck out one at a time. This makes the tests pass instead of fail sporadically. - Fix #160 --- templates_test/relationship_to_one.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates_test/relationship_to_one.tpl b/templates_test/relationship_to_one.tpl index e95c61a..9211284 100644 --- a/templates_test/relationship_to_one.tpl +++ b/templates_test/relationship_to_one.tpl @@ -13,10 +13,10 @@ func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}Using{{$txt. var foreign {{$txt.ForeignTable.NameGo}} seed := randomize.NewSeed() - if err := randomize.Struct(seed, &local, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil { + if err := randomize.Struct(seed, &local, {{$varNameSingular}}DBTypes, {{if .Nullable}}true{{else}}false{{end}}, {{$varNameSingular}}ColumnsWithDefault...); err != nil { t.Errorf("Unable to randomize {{$txt.LocalTable.NameGo}} struct: %s", err) } - if err := randomize.Struct(seed, &foreign, {{$foreignVarNameSingular}}DBTypes, true, {{$foreignVarNameSingular}}ColumnsWithDefault...); err != nil { + if err := randomize.Struct(seed, &foreign, {{$foreignVarNameSingular}}DBTypes, {{if .ForeignColumnNullable}}true{{else}}false{{end}}, {{$foreignVarNameSingular}}ColumnsWithDefault...); err != nil { t.Errorf("Unable to randomize {{$txt.ForeignTable.NameGo}} struct: %s", err) }