Test the to_one eager loading.

This commit is contained in:
Aaron L 2016-08-17 18:53:08 -07:00
parent 3ecb8f96c0
commit e3ff48e647

View file

@ -40,6 +40,21 @@ func test{{.LocalTable.NameGo}}ToOne{{.ForeignTable.NameGo}}_{{.Function.Name}}(
if check.{{.Function.ForeignAssignment}} != foreign.{{.Function.ForeignAssignment}} {
t.Errorf("want: %v, got %v", foreign.{{.Function.ForeignAssignment}}, check.{{.Function.ForeignAssignment}})
}
if err = local.Relationships.Load{{.Function.Name}}(tx, false, {{.LocalTable.NameGo}}Slice{&local}); err != nil {
t.Fatal(err)
}
if local.Relationships.{{.Function.Name}} == nil {
t.Error("struct should have been eager loaded")
}
local.Relationships.{{.Function.Name}} = nil
if err = local.Relationships.Load{{.Function.Name}}(tx, true, &local); err != nil {
t.Fatal(err)
}
if local.Relationships.{{.Function.Name}} == nil {
t.Error("struct should have been eager loaded")
}
}
{{end -}}